Jump to content

PHP File (Size) Download Limit?


kool_samule

Recommended Posts

Hi Chaps,

 

I'm using readfile to force the download of a file:

 

set_time_limit(0);

$file = 'monkey.gif';

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
flush();

 

 

And this works fine, however, I do have some software installation files that could be downloaded (these are in excess of 280Mb).

I have checked php.ini:

memory_limit = 128M

post_max_size = 300M

But Internet Explorer hangs and then crashes.

Is there a way to allow big files to download using this method, or is there another way of forcing the download, without php 'reading' the file first?

I'm guessing that the problem lies with the memory_limit being smaller than the file size. Is it a good idea to increase the memory_limit to eg. 280Mb?

Cheers

Link to comment
https://forums.phpfreaks.com/topic/212840-php-file-size-download-limit/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.