View Full Version : back end image upload

06-30-2008, 03:29 PM
i am making it so i can upload an image to match a product from the back end of my site. i have decided to store the image as a blob ( i know its not the best way)

i found an online tutorial walking me through ti but i want it to be as simple as possible so the only database entrys i want for the image will be product_id and image (blob) i want this to connect with my products table (product_id) i have it set to the exact same value and with auto increment
will this work? i would simply try it but i am stuck on this part of my coding

this is on the end of my form for adding new products but i am coming up with a few errors

if ($submit) {

// connect to the database

$image= addslashes(fread(fopen($form_data, "r"), filesize($form_data)));

$result=MYSQL_QUERY("INSERT INTO images (image) ".
"VALUES ('$image')");

$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";


} else {

// else show the form to submit new data:


<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
File Description:<br>
<input type="text" name="form_description" size="40">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>File to upload/store in database:<br>
<input type="file" name="form_data" size="40">




just a lead in the general direction and i should be ok by following the tutorial i just want ot make sure my logic is right

06-30-2008, 06:01 PM
i advise that you only store the image as a link keeping the image as a file on the server. By using a blob (hehe) will add weight to the server and there is more work to be done.

I strongly advise that you rethink this

please refer to my upload tutorial for a simplified version of what you want

06-30-2008, 07:35 PM
i just finished your tutorial thank you very much