Upgrading my test PHP servers on Windows Nt/2000 OS from PHP 4.1.2 to PHP 4.3.0 i got in trouble with gd library functionality.
Really, some month ago i coded a script to upload an image file (png, jpg formats) in a mysql database as a long blob image. The script under PHP 4.1.2 was working fine. Now, under PHP 4.3.0 (nothing change if i use gd.dll or gd2.dll) when the PHP form script executes the upload of blob image into mysql database it cut off the image file.
The code of the pushing action is:
<?php
...
if (isset($news_photo) && $news_photo != "none") {
// replace string ...\... ......
//$mstr=preg_replace("[\x5c{2}]","\",$news_imgpath);
// replace local drive units with their hostname
$imgpath = preg_replace("/.:/",$host_path, $news_imgpath);
$news_imgfile = addslashes(fread(fopen($news_photo, "r"), filesize($news_photo)));
$news_ftype = $FILES['news_photo']['type'];
$news_fsize = $FILES['news_photo']['size'];
$size = @getimagesize($news_photo);
$imgwidth = $size[0];
$imgeigth = $size[1];
$sstr = "INSERT INTO $table_news (news_user, news_title, news_date, news_day, news_month, news_year, news_short, news_long, news_hits, news_photo, news_ftype, news_fsize, news_class, news_imgpath, news_imgwidth, news_imgeigth) "."VALUES ('$news_user', '$news_title', '$news_date', '$news_day', '$news_month', '$news_year', '$news_short', '$news_long', '$news_hits', '$news_imgfile', '$news_ftype', '$news_fsize', '$news_class', '$imgpath', '$imgwidth', '$imgeigth')";
}
...
During upgrading from PHP 4.1.2 to PHP 4.3.0 nothing was changed.
Register_Gloabals was set to "Off" in PHP 4.1.2 too.
Server configurations:
1) Win NT 4 SP5 + Mysql_3.23.39 + IIS 4.0 + PHP4.1.2 (gd library >= 1.6.2) -> PHP 4.3.0 (gd library 2.0 bundled)
1) Win 2000 SP3 + Mysql_3.23.49 + Apache 1.3.27 + PHP4.1.2 (gd library >= 1.6.2) -> PHP 4.3.0 (gd library 2.0 bundled)
In both cases the script works good under PHP 4.1.2 and cut off the image under PHP 4.3.0 (or PHP 4.2.3).
I thought there was a problem with new realeses of gd.dll and gd2.dll (i used the ones of official win32-zip distributions) but i did not realized what it was.
I enclose below a zip file with image contents before (original) and after blob (blob) insertion into mysql data plus php.ini.
Thanks to all which could help me.