
06-26-2012, 04:54 PM
|
|
Member
|
|
Join Date: Apr 2012
Posts: 10
|
|
Thanks for the reply,
I think this isn't the problem. The content is sent in small pieces.
My Max Dynamic Response Body Size is set to 500M and I can usually set up to 2147483647, download size appears and download starts (and complete).
If I do not define the Content-Length header, download generally occurs without showing the file size.
I think it's a problem with the interpretation of Content-Length header.
Maybe a bug with integer type.
This is what I have:
PHP Code:
<?php define('CHUNK_SIZE', 1024*1024); // Size (in bytes) of tiles chunk
// Read a file and display its content chunk by chunk function readfile_chunked($filename, $retbytes = TRUE) { $buffer = ''; $cnt =0; // $handle = fopen($filename, 'rb'); $handle = fopen($filename, 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { $buffer = fread($handle, CHUNK_SIZE); echo $buffer; ob_flush(); flush(); if ($retbytes) { $cnt += strlen($buffer); } } $status = fclose($handle); if ($retbytes && $status) { return $cnt; // return num. bytes delivered like readfile() does. } return $status; }
$filename = '/media/Test/Files/BigFile.rar'; $mimetype = 'application/x-rar-compressed'; $sz= filesize($filename); header('Content-Type: '.$mimetype ); header('Content-Disposition: attachment; filename="'.basename($filename).'"'); header("Content-Length: ".$sz); readfile_chunked($filename);
?>
This will not start the download.
If I change
header("Content-Length: ".$sz); to header("Content-Length: ".(2147483647));
It works, and to
header("Content-Length: ".(2147483648));
don't work.
Please help me
|