我有一個PHP腳本,應該允許用戶下載文件時不顯示URL。當我嘗試以下時,我下載的文件是空的。有人可以幫忙嗎?如何隱藏下載鏈接
<?php
$file_name = 'test.exe';
$file_url = 'https://www.example.com/' . $file_name;
header('Content-Type: application/octet-stream');
header("Content-disposition: attachment; filename=".$file_name);
readfile($file_url);
?>
example.com是您的網站還是遠程位置? – JohnnyFaldo
看到http://stackoverflow.com/questions/7263923/how-to-force-file-download-with-php – andrewb