Hi All, I'm using a download script to download files from my site just so I don't show the file path and don't allow direct downloads. Here's the part that does the download after the database and logging stuff are taken care of: $speed = 500; $fsize = filesize($fullPath); 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: ".$mime_type); header("Content-Disposition: attachment; filename=\"".$row["file_name"]."\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . $fsize); $file = @fopen($fullPath,"rb"); if ($file) { while(!feof($file)) { echo fread($file, round(1024*$speed)); flush(); sleep(1); if (connection_status()!=0) { @fclose($file); die(); } } @fclose($file); } Code (markup): Now I have two questions/problems: 1) my speed is set to 500, doesn't that mean max 500KB/sec? why am I only able to download at around 250KB/sec? If I remove the speed limits, then I can download up to 1.5MB/sec. 2) The main issues with this download script is while a file is being downloaded, I can't navigate to any other page on my site. even if I have 3 or 4 tabs/windows open, none of the links within my site work anymore in any of the other windows until the download is completed. I can however, navigate around the internet in other sites, just not my own site. I'm pretty sure the issue is my download script because if I allow direct downloads, then I can navigate within the site while the file is being downloaded. Thank a lot in advance for all your help.
If you'd like to test what I'm talking about, use this link: http://www.spidersend.com/download.php?code=74ba7fa4-7d5b-4ad9-b83a-3eef73e7c6df&filename=Pro_Drupal_Development_Second_Edition.pdf as you can see, while the file is being downloaded you can't navigate to any other page even if you open it up in another page or tab.
That was exactly my problem. Someone else mentioned it to me already. thank you for the post as well. Now I just have to figure out how to keep my user logged in while he's downloading a file. If I kill the session, the user will be logged out and that's not what I want. Thanks again for your reply. Cheers
I found this immediately, hope it's the solution you need (obviously it might need more research): http://www.php.net/manual/en/function.session-write-close.php#54838
You are amazing All I had to call was session_write_close(); instead of session_destroy(); that way the session stays open and my problem is solved. Thank you sooo much.