Using the how to store binary info into a MySQL DB article I am now able to store an uploaded file into a LONGBLOB field. However, the fread is corrupting the data. I put a sleep statement in so I could look at the TMP file, and it is just fine. The image opens up great. However, if I fread the file and then fwrite it to another location, the written file is garbled, and won't open in any image program. As a result the page I wrote that presents the image out of the database also acts like the image is invalid. I'm using PHP 4 on a Windows 2000 box as my dev machine, and am using the "rb" flags when reading. Could anyone tell me what I'm doing wrong?
Thanks in advance,
Jason
///STORE CODE, $picture IS THE TEMP FILENAME
if($picture) {
$fp = fopen($picture, 'rb');
$t_pic = AddSlashes(fread($fp, filesize($picture)));
fclose($fp);
echo "<BR>Filename: $picture <BR> File Size: " . filesize($picture) . "<BR> File Type: $picture_type <BR>";
}