私のブラウザでは、すべての形式、zip、kml、pdf をダウンロードできますが、iPhone または iPad から試してみると、zip と kml では機能しますが、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');
それはアップルのデバイスでも機能しませんでした。
助けていただければ幸いです。