-1
對於我自己的網站我想要一個頁面,您可以從這裏下載.rar文件。但是,當我下載並打開文件。我收到一個消息框說:「找不到檔案。」已下載.RAR文件沒有任何內容。
我不知道該怎麼辦,這是我的代碼。
$filename="inputValidatorCasd.rar";
$file="c:\\wamp\\www\\DennisWeb\\Files\\$filename";
$len = filesize($file);
ob_clean();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type:application/octet-stream");
$header="Content-Disposition: attachment; filename=$filename;";
header($header);
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$len);
@readfile($file);
exit;
我沒有收到錯誤。 –
嘗試從'@readfile($ file)'中刪除'@',您可能會收到錯誤消息。 '@'可以消除錯誤,這是一個非常糟糕的做法。 –
沒有,沒有改變。 –