Hi,
I wrote a little script that allows users to upload thier photo, this image is then stored into mysql table into a LONGBLOB field
here the code :
<?
@mysql_connect('host', 'username', 'password');
if ($submit) {
$file_size = filesize ($fichier_image);
$fp = fopen ($fichier_image, 'r'); // or $fp = fopen($fichier_image, 'rb');
$data = addslashes (fread ($fp, $fichier_image));
fclose ($fp);
unlink ($fichier_image);
$sql = "INSERT INTO table_images (bin_data, taille, nom, type)
VALUES
('$data','$fichier_image_size','$fichier_image_name','$fichier_image_type')";
// and then I run the query
$result = @mysql_db_query('mabase', $sql);
}
?>
<FORM ACTION="myscript.php" METHOD="post" name="eForm" enctype="multipart/form-data">
<INPUT TYPE="File" NAME="fichier_image">
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="1000000">
<INPUT TYPE="submit" NAME="submit" value=" Ok ">
</FORM>
The script works perfectly under Redhat 7.1/Apache/PHP 4.0.6
but does not work clean under windows 2000 avec easyphp 1.5 (Apache/Mysql/PHP4.0.6)
Magic_quotes settings under win2k an linux are :
magic_quotes_gpc On
magic_quotes_runtime Off
The problem is : when the query is executed the binary data into the blob is corrupted.
Anyone has met the same problem ?
Thanks.