From: trendboy at gmail dot com Operating system: Linux PHP version: 5.2.6 PHP Bug Type: Streams related Bug description: Image does not get uploaded corrected to DB from a URL
Description: ------------ When you upload an image to a DB from a URL it seems as though only "half" the image is uploaded. (See image URLs below for working example) It is very odd. I've experienced the same issue by just saving it to a file so it seems it is not database related. Steps to recreate: 1) Create a page that uploads an image from a URL. (code below) 2) Create a page to view that image (code below) 3) Your image will only be "half uploaded" the image is half displayed yet a full image appears (just "white" half way). Reproduce code: --------------- Code of uploader: (feel free to use my test image, it's my server) // Database connection strings I've hidden here of course // // $tmpName = "http://www.irishtarot.com/images/header.jpg"; function getSizeFile($url) { if (substr($url,0,4)=='http') { $x = array_change_key_case(get_headers($url, 1),CASE_LOWER); if ( strcasecmp($x[0], 'HTTP/1.1 200 OK') != 0 ) { $x = $x['content-length'][1]; } else { $x = $x['content-length']; } } else { $x = @filesize($url); } return $x; } $fp = fopen($tmpName, 'r'); $content = fread($fp, getSizeFile($tmpName)); $content = addslashes($content); fclose($fp); mysql_query("insert into thumbnail (image) values ('" . $content . "')"); Expected result: ---------------- The full image should be uploaded, but is isn't. It is almost like it "crashes" half way during the download and upload to the DB. At first I thought it was because the getSizeFile() method I created didn't wory so I echo'd it's size result but it is correct. So is there something wrong with fread() when used with a reference to a URL rather than a file?? Very confused :-) Actual result: -------------- "half image" Example: The REAL image: http://www.irishtarot.com/images/header.jpg The HALF IMAGE generated from the DB (the Half Image): http://www.guysonfilm.com/webmaster/previewad.html Crazy stuff :) -- Edit bug report at http://bugs.php.net/?id=45842&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45842&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45842&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45842&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45842&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45842&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45842&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45842&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45842&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45842&r=support Expected behavior: http://bugs.php.net/fix.php?id=45842&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45842&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45842&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45842&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45842&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45842&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45842&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45842&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45842&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45842&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45842&r=mysqlcfg
