php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14390 HTTP Upload files missing few bytes from end
Submitted: 2001-12-09 07:08 UTC Modified: 2001-12-09 11:02 UTC
From: dannytuppeny at ntlworld dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.1.0 OS: WinXP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dannytuppeny at ntlworld dot com
New email:
PHP Version: OS:

 

 [2001-12-09 07:08 UTC] dannytuppeny at ntlworld dot 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-09 10:53 UTC] sander@php.net
On Windows, you should use 'b' while opening binary files.
$wfp = fopen($DOCUMENT_ROOT . '/dbimages/' . $file, 'wb');


 [2001-12-09 11:02 UTC] dannytuppeny at ntlworld dot com
oh right! I never did on WinME though!

Thanks.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 17:01:30 2025 UTC