0
我的问题是,我的浏览器下载脚本将文件内容写入浏览器,并且不会将其作为文件从浏览器下载。PHP浏览器 - 文件下载
我的供应商是Strato。 (www.strato.de)
我使用这个PHP脚本下载文件:
if(file_exists($backup_file_path)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($backup_file_path).'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($backup_file_path));
ob_clean();
flush();
readfile($backup_file_path);
exit;
echo "<script>console.log('Download success');</script>";
}
在与XAMPP它正在本地主机,但在灵云出现我所描述的问题。
请帮助我,如果你可以。 谢谢!
PS: PHP版本:5.5
谢谢您的回答! - 我试过你的版本,但没有改变。与以前相同的问题 - 脚本将内容写入浏览器,但不下载文件。 –
我认为你的问题出现在www.strato.de托管的'php.ini'中,为了解决你的问题,你可能需要联系你的托管服务,并要求开一张协助票。如果脚本也适用于Windows,那么唯一有罪的可能是Strato Hosting在他们的'php.ini'中存在一些问题。你可以在Windows上比较你的'php.ini'和Strato上的'php.ini'。为此,创建一个名为info.php的php文件并放入这行''?php phpinfo();然后上传到您的Strato网络空间,并将相同的文件放在Windows下的网络空间中。看到'php.ini'的差异。 – Alessandro