Unable to Upload Blob Image

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shazz256
Forum Newbie
Posts: 1
Joined: Wed Jun 03, 2015 12:36 am

Unable to Upload Blob Image

Post 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>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Unable to Upload Blob Image

Post by Celauran »

Table name shouldn't be in quotes. You want backticks.
Post Reply