From: ivan at artenergy dot com
Operating system: FreeBSD 4.7/Apache1.3.27
PHP version: 4.3.2
PHP Bug Type: Filesystem function related
Bug description: File corruption during file upload

Description:
------------
Uploading files, e.g. JPGs or GIFs, using HTML form/PHP interface results
in corrupted files.

Reproduce code:
---------------
HTML form fragment:
....
<form method="post" enctype="multipart/form-data"
action="update.php"><input type="file" name="image">
.....

update.php fragment:
....
copy("$image", "/www/image/$image_name") or die("Couldn't upload
$image_name !");
....

Expected result:
----------------
Selected local file uploaded to the web server as
"/www/image/$image_name"

Actual result:
--------------
File is indeed uploaded, file length is correct, but it is
corrupted.
Typically all 0x00 bytes are replaced with 0x20.

--
Edit bug report at [url]http://bugs.php.net/?id=24574&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=24574&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=24574&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=24574&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=24574&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=24574&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=24574&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=24574&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=24574&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=24574&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=24574&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=24574&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=24574&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=24574&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=24574&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=24574&r=gnused[/url]