我有一个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