I’m using a upload script with ajax and PHP and it works wonders for files smaller than 80MB. However, if the file is bigger than 80MB it fails, it doesn’t even output anything at all.
The code is:
$maxsize = getMaxFileSize();
$finalfile = $uploadpath . $finalname;
$putdata = fopen("php://input", "r");
$fp = fopen($finalfile, "w");
$filesizecalc = 0;
while ($data = fread($putdata, 1024)) {
fwrite($fp, $data);
$filesizecalc = $filesizecalc + 1024;
}
fclose($fp);
fclose($putdata);
if ($filesizecalc <= $maxsize) {
addFile($_SESSION['userdata']['userid'], $finalname);
echo "$fn uploaded";
} else {
unlink($finalfile);
}
exit();
This works fine with almost all files < 80 MB, but for files bigger than 80MB it doesn’t output a thing, so I don’t even know what’s going wrong, even though I set
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);
ini_set('memory_limit', '1024M');
ini_set('upload_max_filesize', '1024M');
ini_set('post_max_size', '1024M');
ini_set('max_input_time', 10000);
ini_set('max_execution_time', 10000);
Lets write it down as solution so it can be read correctly rather than digging in the comments.
variables cannot be changed from the script there are ~ 6 different
values controlling big uploads. Check ALL of them (the list and the
explemenations can be found here )
error_log file for the real error. (or check the access_log to see
what was the request status returned by the server)
some Application firewall or apache config that limits the request
time. In this case you’ll see response code such as “connection
reset”.
Try the W3Scools upload script: