filmixt

Registered
Jun 7, 2009
2
0
51
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
 

filmixt

Registered
Jun 7, 2009
2
0
51
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($url, 1),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($fp, 99999);
	        set_time_limit(99999);
	   ob_flush();
	   flush();
	   
}
fclose( $fp );

?>
Is there a limitation in cpanel?
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
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.