我试图解决我的问题几个小时并搜索谷歌和几个板,但我还没有找到解决方案。
我的问题:我构建了一个 PHP 脚本来生成下载。下面的代码:
$file = "file.pdf";
$download_folder = "../contents/"; //RELATIV
$type= mime_content_type($download_folder.$file);
header("Content-Type: $type");
header("Content-Disposition: attachment; filename=\"$file\"");
readfile($download_folder.$file);
如果我在我的本地主机服务器(xampp)上尝试它,它可以工作并且文件的下载开始。如果我将脚本上传到我的托管服务器(不是自己的,它已经消失了),我只会得到一个空白页。
有任何想法吗?谢谢!