Uploading Files With PHP - Upload Only One At A Time!
I have a PHP file that serves the file, but the problem is that no matter what browser is used, if you click on 2 links that go to 2 separate files, the second download doesn't start until the first one is finished! Any ideas?
Download code
header('Content-Type: application/octet-stream');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($fullpath));
readfile($fullpath);
Link examples
- Link 1: download.php? downloadfile = 1
- Link 2: download.php? downloadfile = 2
source to share
There may be various reasons for this.
-
You are using sessions. Therefore, only one script at a time is allowed to change the session. So, download B can only start after download A. has finished downloading two at the same time as download A in browser A and download B in browser B? Look at the description of session_write_close
-
Some other HTTP issues where your browser won't open multiple connections to the server but reuse one connection and of course it has to wait for the first request to complete.
-
Some OS / Webserver settings that allow a very limited number of open concurrent connections either in general or on the host
source to share