在我的浏览器中,我可以下载所有格式,zip、kml、pdf,但是当我从 iphone 或 ipad 尝试时,它适用于 zip 和 kmls,但不适用于 pdf。有人可以指出我做错了什么吗?我正在使用的代码是:
<?php
$file = "/raid0/data/naswebsite/Projects/Projects/" . $_GET["file"];
$parts = explode('/', $file);
$download = $parts[count($parts) - 1];
if (!file_exists($file))
{
echo "The file $file does not exist on the server.";
exit;
}
if (strpos(strtolower($file), ".zip"))
{
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' .urlencode($download));
header('Content-Transfer-Encoding: binary');
}
else if (strpos(strtolower($file), ".pdf"))
{
header('Content-Type: application/vnd.adobe.pdf');
header('Content-Disposition: attachment; filename=' .urlencode($download));
header('Content-Transfer-Encoding: binary');
}
else if (strpos(strtolower($file), ".kml"))
{
header('Content-Type: application/vnd.google-earth.kml+xml');
header('Content-Disposition: attachment; filename=' .urlencode($download));
header('Content-Transfer-Encoding: binary');
}
else
{
header('Content-Type: application/text');
header('Content-Disposition: attachment; filename=' .urlencode($download));
header('Content-Transfer-Encoding: binary');
}
readfile($file);
?>
我还要注意我尝试过使用
header('Content-Type: application/pdf');
这也不适用于苹果设备。
帮助表示赞赏。