Hi all,
Could you please tell me what pitfalls are in File Upload on Linux.
There is my code example:
<?php
if($POST != NULL);
{
if(array_key_exists('send', $POST))
{
$uploadfile = $FILES['file1']['tmp_name'];
$uploaddir = '/var/www/web_latauto/upload/' . $FILES['file1']['name'];
if (move_uploaded_file($uploadfile, $uploaddir)) {
print "File is valid, and was successfully uploaded. Here's some more debugging info:\n";
print_r($FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($FILES);
}
}
}
?>
<html>
<body>
<FORM ACTION="info.php" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="2000047">
Send this file: <input name="file1" type="file">
<input type="submit" name="send" value="Send File">
</form>
</body>
</html>
This example works fine for me on Windows, but when I tried to run it on Linux, I was surprised that uploaded file size was greater than I send.
For example I tried to upload file passat.jpg (size - 5195 bytes).
The $_FILES array looks like:
Array ( [file1] => Array ( [name] => passat.jpg [type] => image/pjpeg [tmp_name] => /tmp/phpsWjKkO [error] => 0 [size] => 8115 ) )
Uploaded file size now is 8115 bytes???
Could you please explain how can I solve this problem, is my php code correct or there are some php.ini settings problem.
Thanks,
Vlad