• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
read_file and force_download, memory limits?

#2
[eluser]darrenm[/eluser]
I've just finished a project that had just this problem.

There are two php.ini settings that are likely to give you trouble:

memory_limit and max_execution_time

If you use force_download() to serve the file in one go, you're likely to have trouble with memory_limit (you'll probably need double the size of your file). The alternative is to use something like this:

Code:
$handle = @fopen($path,"r");
if ($handle) {
   while (!feof($handle)) {
      $buffer = fgets($handle);
      echo $buffer;
   }
   fclose($handle);
}

Which serves the file one line at a time. The danger in that is that you'll hit max_execution_time. Fortunately for my project the host had that set to 50000 so it was never an issue. had it been a problem I was going to see if I could reset the ini value regularly within the loop.


Messages In This Thread
read_file and force_download, memory limits? - by El Forum - 10-16-2008, 02:30 AM
read_file and force_download, memory limits? - by El Forum - 10-16-2008, 05:15 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.