使用PHP寫出下載檔案的網頁

$path = "file/download.exe"; //路徑及下載的檔案
$name = "newfileName.exe"; //下載後的檔名
if (!file_exists($path))
echo "錯誤";
else {
header("Content-type: application/download");
header("Content-Disposition: attachment; filename=$name");
header("Content-Transfer-Encoding: binary");
readfile($path);
}


感謝作者,PHP真是一個好用的網頁語法.

引用來源