Heres what i got:
session_start();
function send_file($path, $name) {
ini_set("max_execution_time", "".(60*60*24)); // 24 hours
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Length: '.filesize($path));
header('Content-Disposition: attachment; filename="'.$name.'"');
header("Pragma: no-cache");
header("Expires: 0");
$fp = fopen($path, 'rb');
while(!feof($fp)) {
if(connection_aborted()) die();
echo fread($fp, 1024);
flush();
}
fclose($fp);
}
if (@$_SESSION['fid'] == base64_encode(session_id()))
send_file(base64_decode($_SESSION['file']),base64_decode($_SESSION['fname']));
Now, heres my problem;
Everything works fine exept rar files, i tryed: rar, zip, txt, asm
a 302 byte rar file only sends 287 bytes :S i checked the filelength, which was 302 in the header.
maybe something in in the rar's end of file?
oh, and 1 more funny thing, if i remove the content-length header, it works. but i need it...
output for
die('Content-Length: '.filesize($path));
was Content-Length: 302
Apache 1.3.X, PHP 5.1