Hellow all,
I have small problem with PHP 4.31 and Apache 2 on Win2k. I'm using simple script to download files with support of ressuming. It's perfect but when download is finished then apache still takes lot of memory. After few downloads apache takes 200MB of RAM and I must restart it.
Please help me.
Thanx!
Here is my code:
<?
header("HTTP/1.1 206 Partial Content");
$filename=$QUERY_STRING.".rm";
$file="E:\\Archiv\\" . $filename;
if ($HTTP_RANGE)
{
$pos=strpos ($HTTP_RANGE, "bytes=");
$pos2=strpos($HTTP_RANGE,"-");
$bytes=substr ($HTTP_RANGE, $pos+strlen("bytes="),$pos2-($pos+strlen("bytes=")));
$ultimobyte=substr($HTTP_RANGE,$pos2+1,strlen($HTTP_RANGE));
}
else
{
$bytes=0;
}
settype ($bytes, "integer");
settype ($ultimobyte,"integer");
if ($ultimobyte!=0)
{
$hasta=$ultimobyte;
}
else
{
$hasta=filesize($file)-1;
}
$largo=$hasta-$bytes+1;
$ttotal=filesize($file);
error_reporting(0);
header("Last-Modified: " . gmdate("D, d M Y H:i:s T", filemtime($file)));
header("Accept-Ranges: bytes");
header("Content-Length: " . $largo);
header("Content-Disposition:attachment; filename=".$filename);
header("Content-Range: bytes ".$bytes."-".$hasta."/".$ttotal);
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Transfer-Encoding: binary");
header("Pragma:no-cache");
header("Expires:0");
set_time_limit(0);
$fp = fopen($file,'rb');
if (!$fp) {
echo "Error opening file!!!";
exit();
}
rewind ($fp);
fseek ($fp, $bytes);
fpassthru($fp);
fclose($fp);
header("Connection: close");
exit();
?>