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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 06:01:29 2024 UTC