0

I'm trying to set up an Apache2 webserver with PHP on Windows. I'm using the EasyPHP package to install the required servers. Everything works fine as long as I want to host larger files for downloads. By large I mean 34M. When I try to download such a file, the request times out. If I try to download a smaller file with the same filename, it works. I have no idea what could cause this. I try to access the files directly on the server, but also fails if I try to fetch with some PHP code. I have LimitRequestBody set to 0 in httpd.conf and I can't find any option that might has an effect on this.

EDIT: The download fails when no PHP is used, and I'm trying to download the file with direct link. So I don't really think it's a problem related to PHP, rather to apache.

Any help would be appreciated.

2 Answers2

0

I'd like to credit for this but it has been asked and answered a bunch of times. How to increase maximum execution time in php

Marked as answered if you find this answer useful.

Community
  • 1
  • 1
  • Thank you, but it does not work. No matter if I set some high value to max_execution_time, I always fail to download the file. It's not something that the download is interrupted, but if I try to download a file larger than 34M, I get a "connection was reset" message in the browser, I can't start the download at all. – Tamás Kovács Feb 17 '17 at 17:53
  • I also have everything described in the "duplicate posts" set, but still have this problem. – Tamás Kovács Feb 17 '17 at 17:58
0

I found the answer for this here: https://serverfault.com/questions/115906/is-there-some-limit-on-a-size-of-a-file-when-force-downloading-it-with-php-on-ap

The memory limit didn't help, but using the readfile_chunked function worked! Thank you from here too!

<?php 
function readfile_chunked ($filename) { 
  $chunksize = 1*(1024*1024); // how many bytes per chunk 
  $buffer = ''; 
  $handle = fopen($filename, 'rb'); 
  if ($handle === false) { 
    return false; 
  } 
  while (!feof($handle)) { 
    $buffer = fread($handle, $chunksize); 
    print $buffer; 
  } 
  return fclose($handle); 
} 
?>
Community
  • 1
  • 1