Reputation: 9782
I have small chunk of code that helps to download a file. But the site not opened/work during file download, but when i open the site on other browser then its working. I don't have any idea what going on with the browser during file download. Here are the headers that i am using to download a zip file:
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=\"".$zipname."\"");
header("Content-Transfer-Encoding: binary");
//header("Content-Length: ".filesize($directory_location . '/' . $zipname));
ob_end_flush();
readfile($directory_location . '/' . $zipname);
ob_end_clean();
Even i don't know how to debug it, so that i get the weak point from my codes.
Upvotes: 0
Views: 58
Reputation: 96339
So since you are using sessions:
An “open” session blocks other scripts from accessing the session while your download script is running.
session_write_close
before streaming the file content to the client fixes that. Just call it after you are done with checking whatever you need to check in the session, and before the time-consuming part of the script begins – that will release the lock on the session, and other scripts that are called while the download script is running can access the session again.
Upvotes: 1