Bug #14390 Updated: HTTP Upload files missing few bytes from end
| From: | sander@php.net | Date: | Sun, 09 Dec 2001 15:53:21 +0000 |
| Subject: | Bug #14390 Updated: HTTP Upload files missing few bytes from end | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-73158@lists.php.net to get a copy of this message | ||
ID: 14390
Updated by: sander
Reported By: dannytuppeny@ntlworld.com
Old Status: Open
Status: Bogus
Bug Type: Filesystem function related
Operating System: WinXP
PHP Version: 4.1.0
New Comment:
On Windows, you should use 'b' while opening binary files.
$wfp = fopen($DOCUMENT_ROOT . '/dbimages/' . $file, 'wb');
Previous Comments:
------------------------------------------------------------------------
[2001-12-09 07:08:32] dannytuppeny@ntlworld.com
I have some scripts used to upload gifs. The form has the right enctype, and the script looks like:
==
list($filename, $fileext) = explode(".", basename($upfile_name));
$file = $filename . '.' . $fileext;
if (file_exists($DOCUMENT_ROOT . '/dbimages/' . $file)) {
$i = 0;
while(file_exists($DOCUMENT_ROOT . '/dbimages/' . $file)) {
$i++;
$file = $filename . '(' . $i . ').' . $fileext;
}
}
$rfp = fopen($upfile, 'r');
$wfp = fopen($DOCUMENT_ROOT . '/dbimages/' . $file, 'w');
fwrite($wfp, fread($rfp, filesize($upfile)));
fclose($wfp);
fclose($rfp);
==
But the uploaded file is missing a few bytes. Check out the screenshot below. It's only about 5
bytes missing, but that doesn't help a browser trying to render the image.
I downloaded a windows binary about 2 weeks ago and installed it on winxp/apache. If you need any
other info, just ask.
http://customfones.com/temp/php_upload.GIF
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=14390&edit=1