Page 1 of 1

Corrupted File After File Upload - file size is different

Posted: Thu Sep 12, 2013 6:18 pm
by marywang
Hi,
I'm running on RHEL 6.2, PHP 4.4.9 and Apache 2.2.15, after the most recent upgrade the file upload logic no longer works. Basically, the file upload seems to be uploaded successfully (no errors returned), but the file is corrupted. The file types can be any file types, and the file size of the uploaded file is always larger than original size. I just compared the source .txt file to the destination .txt, the destination file includes "Content-Disposition: form-data; name="file"; filename="final.txt"
Content-Type: text/plain" in the .txt file. Basically, it added extra text to the destination file. I am not sure what is going on.

I'm not sure if I need to configure something in php.ini or httpd.conf with this error. Any help would be appreciated. Mary

Below is the code that I tried to test:
<html>
<body>
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
// echo "Stored in: " . $_FILES["file"]["tmp_name"];
if (file_exists("/tmp/wangtest/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"/tmp/wangtest/" . $_FILES["file"]["name"]);
echo "Stored in: " . "/tmp/wangtest/" . $_FILES["file"]["name"];
}
}
?>
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>

</body>
</html>

Re: Corrupted File After File Upload - file size is differen

Posted: Thu Sep 12, 2013 7:39 pm
by Celauran
marywang wrote:PHP 4.4.9
Please tell me this is a typo. That version is five years old.