DanR Posted May 16, 2008 Share Posted May 16, 2008 Hey there guys. Basically I am running a PHP script that reads a file from outside of wwwroot to deliver it to the browser, however, when this script is running and the download is in progress that particular visitor cannot change pages or download anything else until the browser is complete, the site becomes inaccessible virtually and just shows a progress bar until the download is finished, and once that's done the site works. The script I am using is the following readfile chunked function readfile_chunked($filename,$retbytes=true) { $chunksize = 1*(1024*1024); // how many bytes per chunk $buffer = ''; $cnt =0; // $handle = fopen($filename, 'rb'); $handle = fopen($filename, 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { $buffer = fread($handle, $chunksize); echo $buffer; ob_flush(); flush(); if ($retbytes) { $cnt += strlen($buffer); } } $status = fclose($handle); if ($retbytes && $status) { return $cnt; // return num. bytes delivered like readfile() does. } return $status; } [ I really don't know where this problem is coming from, I've tried altering PHP output buffering and tweaking a few settings in my apache2 conf. I initially thought the PHP output buffering could possibly be affecting the complete visitor session, but after a little tweaking this doesn't appear to be the case. I'm running PHP 5.1.x with Apache 2.0 on an Ubuntu operating system. Any suggestions or anyone encountered this problem before? Quote Link to comment https://forums.phpfreaks.com/topic/105858-solved-apache-config-issue-cant-move-pages-when-php-script-running/ Share on other sites More sharing options...
DanR Posted May 16, 2008 Author Share Posted May 16, 2008 I solved it, I had to add session_write_close(); before the loop, this allowed multiple downloads and page views afterwards. I think this can be moved to the PHP section if possible to help other people? Quote Link to comment https://forums.phpfreaks.com/topic/105858-solved-apache-config-issue-cant-move-pages-when-php-script-running/#findComment-542528 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.