I need help with this code. I am unable to upload image ? Can you please help me identify the issue ?
Thank you in advance.
Code: Select all
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Blob Data Type Tutorial</title>
</head>
<body>
<Form action="index.php" method="POST" enctype="multipart/form-data">
<input type="file" name="image"><input type="submit" name="submit" value="Upload">
</Form>
<?php
if (isset($_POST['submit']))
{
mysql_connect("localhost","root","");
mysql_select_db("blob");
$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"]);
if(substr($imageType,0,5)=="image")
{
mysql_query("INSERT INTO 'blob' VALUES('','$imageName','$imageData')");
echo "Image Uploaded!";
}
else
{
echo "Only images are allowed!";
}
}
?>
</body>
</html>