PHP File (Size) Download Limit?

Discussion in 'PHP' started by koolsamule, Sep 8, 2010.

  1. #1
    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();
    PHP:

    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:
    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
     
    koolsamule, Sep 8, 2010 IP
  2. koolsamule

    koolsamule Peon

    Messages:
    101
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    used

    ini_set('memory_limit', '300M');
     
    koolsamule, Sep 8, 2010 IP