我写了下载rar文件的代码,它工作得很好,但是
$name = 'file.rar';
$data = file_get_contents("file.rar");
$fh = fopen("$name", 'w') or die("can't open file");
fwrite($fh, $data);
fclose($fh);
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Length: ". filesize("$name").";");
header("Content-Disposition: attachment; filename=$name");
header("Content-Type: application/octet-stream; ");
header("Content-Transfer-Encoding: binary");
readfile($name);
exit;
下载后,打开该文件时显示错误意外结束存档,它不会完全提取给我一些建议提前谢谢你