Open New page when downloading is on progress

Hi,
I have a script which prompts user to download a file. The code looks like this

header(“Pragma: public”);
header(“Expires: 0”); // set expiration time
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header(“Content-length: “.filesize(”$filepath));
header(“Content-type: $mime”);
header(‘Content-Transfer-Encoding: binary’);
header('Content-Disposition: attachment; filename=”‘.$some_name.’"');
readfile($filename);
exit(0);

With this script download dialog box appears and we can download or save files from browser. But when the file is being download, the site hangs i.e. no other pages can be navigated. Site just stays on the similar page. If anyone has idea on this, please let me know.

Thank you

I have seen a similar effect for some scripts doing large tasks. I suspect it has something to do with how Apache assigns tasks to its child threads. It does not seem to affect other people coming from different IP addresses.

If you’re using sessions, call session_write_close() before outputting the file.