【发布时间】:2015-12-28 09:06:20
【问题描述】:
我有一个名为 openFile.php 的文件,其中包含以下数据:
<?php
$file = $_GET['pathFile'];
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Type: application/octet-stream');
header('Content-Transfer-Ecoding: binary');
header('Content-Disposition: attachment; filename='.basename($file).'');
header('Cache-Control: public');
readfile($file);
exit;
}
else
{
echo("<h1 style='text-align:center;color:red;font-size:bold;'>File ".basename($file)." non trovato !</h1>");
}
?>
我每天在带有 XAMPP 的 Windows 下使用这个脚本并且一切正常,但是我已经用 Ubuntu 14.04 更改了我的服务器,现在当我尝试下载时,我认为浏览器会下载一个没有扩展名且没有内容的文件。
【问题讨论】:
-
这可能是权限问题。你能检查一下你在ubuntu中给这个文件的权限吗?您可以使用命令:chmod 来更改权限。