0
<form method="post" action="uploadfile.php" enctype="multipart/form-data">
    <input type="file" name="file" onchange="this.form.submit()" />
</form>

<!--uploadfile.php-->
<?php
if(!empty($_FILES["file"]["name"])){
if ($_FILES["file"]["error"] > 0){
echo "Error: " . $_FILES["file"]["error"] . "<br>";
die();
}else{
echo "success";
die(); }
}else{ echo "empty file";}  
?>

When I run this code and try to upload a file that is too large one server returns 'empty file' which is ok because I can then put some code to deal with this situation however running the exact code, uploading the exact too large file on a different server produces a 500 error. As far as I can see the ini files on bother servers seem to have the same settings. Can anyone tell me why this is and is there a way to stop it. Also why doesn't loading the oversized file trigger the $Files error code?

pnuts
  • 58,317
  • 11
  • 87
  • 139
user1190323
  • 41
  • 1
  • 6
  • you should have a look at your web server's error log files to see what the error 500 was about – periklis May 29 '13 at 05:49
  • There is no error log produced from the 500 error server and the error log from the other server says the post max size is exceeded which is what I expected – user1190323 May 29 '13 at 05:54
  • perhaps you can turn on error_reporting in your script to see the error. Add this line on top of your script (or right above the point where the upload handling takes place: `error_reporting(E_ALL);ini_set('display_errors',true);` – periklis May 29 '13 at 05:57
  • Just tried that, I put it at the top of uploadfile.php but still getting 500 error – user1190323 May 29 '13 at 06:06

0 Answers0