<?php
if(isset($_POST['submit'])){
mysql_connect('localhost','root','');
$con_db=mysql_select_db('test');
if(!$con_db)echo"Error Connecting";
$imageName = mysql_real_escape_string($_FILES['image']['name']);
$imageData = mysql_real_escape_string(file_get_contents($_FILES['image']['tmp_name']));
$imageType = mysql_real_escape_string($_FILES['image']['type']);
echo $imageName;
if(substr($imageType,0,5)=="image"){
mysql_query('insert into image values("","$imageData","imageName")');
}
else echo "Select Image to Post";
}
?>
<body>
<form action="" method="post" enctype="multipart/form-data">
<table>
<td><tr>Upload image</tr><td><input type="file" name="image"></td>
<td><tr></tr><tr><input type="submit" name="submit"></tr></td>
</table>
I here have created a form and tried to upload the pic it got uploaded when i try to show the uploaded image its showing that there is a fatal error function must be a string
<?php
$my_con=mysql_connect('localhost','root','');
mysql_select_db('test');
$getid = $_GET('id');
if(isset($getid)){
$id = $getid;
$db_query = mysql_query("select * from 'image' where id='$id'");
while($row = mysql_fetch_row($db_query)){
$imageData = $row['image'];
}
header("content-type: image");
}
else{
echo "Error!";
}
?>
This is another php file to display the image