Page 1 of 1

Unable to Upload Blob Image

Posted: Wed Jun 03, 2015 12:42 am
by shazz256
Hey,

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>

Re: Unable to Upload Blob Image

Posted: Wed Jun 03, 2015 7:21 am
by Celauran
Table name shouldn't be in quotes. You want backticks.