Jump to content

RE: Blob upload in an Update query


cdoggg94

Recommended Posts

So im not really sure if this is possible but this is what I am trying to do..

 

I have a table that has a list of products...There is a spot for an image for each of these products.

 

What I want to do is give a user the option to add an image to an existing product.

 

I have one spot for image_name, ie: this_picture.jpg

and

and BLOB field for the image file called: image

 

 

this is my code..

 


mysql_connect("locahost","root","") or die(mysql_error());
mysql_select_db("my_db") or die(mysql_error());

$picture = $_FILES['image']['tmp_name'];

if(!isset($picture))
echo "";
	else
	{
	$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));	
	$image_name = addslashes($_FILES['image']['name']);
	$image_size = getimagesize($_FILES['image']['tmp_name']);

	if($image_size==FALSE)
		echo "This is not an Image";
	else{
			if(!$insert = mysql_query ("UPDATE `Sheet1` SET `image_name` = '".$image_name."', `image`='".$image."' WHERE  pro_id ='".$id."';"))
				echo "Problem Uploading Image.";
			else{
				$lastid = mysql_insert_id();
				echo "Image Uploaded!<p />".$text."<p /><p /> Your Image:<p /><img src=get.php?id=$lastid>";
				}
		}

	}

 

 

The get.php page basically just displays the image and works fine but if you would need to see it for some reason I can provide it.

Link to comment
https://forums.phpfreaks.com/topic/256622-re-blob-upload-in-an-update-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.