Yah, I did do the same thing also, and I check the file and it did store in my MySql db. correctly.
Actually I am try to upload 2 images to db at the same time, but using a similar method as show by you. The first file is uploaded to the server correctly, however, the 2nd file juz can't display when i view it. may be you need to see my coding for this:
++++++++++++++++++++++++++++++
if (!empty($form_data2)) { //if there is thumbnail image
$imagehw2 = GetImageSize($form_data2);
// Do this prior to adding slashes
// to the data.
$imagewidth = $imagehw2[0];
$imageheight = $imagehw2[1];
$imagetype = $imagehw2[2];
$size = filesize($form_data2);
if ($imagetype == '2') {
$form_data2_type = 'image/pjpeg';
}
if ($size >0 ) {
$form_data2 = addslashes(fread(fopen($form_data2, "r"), filesize($form_data2)));
//insert the thumbnail image to object
$res = myquery("insert into object values ('','$size','$imagehw2[0]','$imagehw2[1]','$form_data2_type','$
form_data2_name','".$img['imgdesc']."','".addslashes($form_data2)."','$thumb_id','')", 'object');
$thumb_id = mysql_insert_id();
//insert the thumbnail image object map to objectmap
}
}
if (!empty($form_data)) { //if there is real image to upload
$imagehw = GetImageSize($form_data);
// Do this prior to adding slashes
// to the data.
$imagewidth = $imagehw[0];
$imageheight = $imagehw[1];
$imagetype = $imagehw[2];
$size = filesize($form_data);
$type = '';
if ($imagetype == '2') {
$form_data_type = 'image/pjpeg';
}
$form_data = (fread(fopen($form_data, "r"), filesize($form_data)));
// insert the image to objectbin
$res = myquery("insert into objectbin values ('','$size','$imagehw[0]','$imagehw[1]','$form_data_type','$form_data_n
ame','".$img['imgdesc']."','".addslashes($form_data)."','$thumb_id','')", 'object');
//insert the image object map to objectmap
$image_id = mysql_insert_id();
+++++++++++++++++++++++++
From the above, I only view the image which upload via form_data, the image which upload via form_data2 seem like corrupted when view it. (same image.)
Any idea on this? any advisorble is very appreaciated much. Thanks.
Louis