The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Heavy File Downloads

Discussion in 'cPanel Developers' started by filmixt, Jun 7, 2009.

  1. filmixt

    filmixt Registered

    Joined:
    Jun 7, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hello,
    Im making a script in order to force a download, opening it with fopen() and fread().
    The thing is, everything works great, but if files are larger than 240mb, the thing gets screwed.

    I have configured:

    memory_limit = -1
    max_execution_time = 5400
    max_input_time = 5400

    And set the "maximum memory usage for process until cpanel kills it" to unlimited.

    What can be the problem?
    Im using set_time_limit(99999); too.

    Thanks
     
  2. filmixt

    filmixt Registered

    Joined:
    Jun 7, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Test

    I have runned a test, and it stops at 252,9mb...

    Here you have the code:

    PHP:
    <?php
    // ARCHIVO
          
    $f $_GET["f"];
    // PESO
          
    function urlfilesize($url,$thereturn) {
    if (
    substr($url,0,4)=='http') { 
    $x array_change_key_case(get_headers($url1),CASE_LOWER);
    $x $x['content-length'];
                }
    else { 
    $x = @filesize($url); }
    if (!
    $thereturn) { return $x ; }
    elseif(
    $thereturn == 'mb') { return round($x,2) ; }
    elseif(
    $thereturn == 'kb') { return round($x,2) ; }
    }

    // Tengo PESO
    $peso urlfilesize($_GET[f],'');

    // Headers
          
    $name explode("/"$f);
          
    $nc count($name);
         
    $nombre $name[$nc-1];
            
    header("Content-Description: File Transfer");
          
    header("Content-type: application/octet-stream");
          
    header("Content-Disposition: attachment; filename=\"$nombre\"\n");
          
    header("Content-Length: ".$peso);
          
    header("Cache-Control: no-store, no-cache, must-revalidate");

    // Imprimir
    $fp=fopen("$f""r");
    while(!
    feof($fp)) {

           echo 
    fread$fp$peso);
               
    stream_set_timeout($fp99999);
                
    set_time_limit(99999);
           
    ob_flush();
           
    flush();
           
    }
    fclose$fp );

    ?>
    Is there a limitation in cpanel?
     
  3. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Our technical analysts can look over your configuration settings to see if there's any configuration issue that is causing this to happen: http://tickets.cPanel.net

    Note, if this is a PHP script issue rather than a PHP/server configuration issue, it will be up to you to debug your PHP script.
     
Loading...

Share This Page