1

次の機能を使用してpdfファイルをダウンロードしています。PCまたはラップトップからダウンロードすると正常に動作しますが、iPadを使用してダウンロードリンクをクリックすると、多くの特別な文字が含まれるページが開き、ファイルをダウンロードできません.

私のダウンロード機能は

public function download() {
    $download_path = $_SERVER['DOCUMENT_ROOT'] . "/import";
$filename = $_GET['file'];
    $file = str_replace("..", "", $filename);
    $file = "$download_path/$file";
if (!file_exists($file))
        die("Sorry, the file doesn't seem to exist.");
    $type = filetype($file);
    header("Content-type: $type");
    header("Content-Disposition: attachment;filename=$filename");
    header('Pragma: no-cache');
    header('Expires: 0');
    readfile($file);
}

このエラーについて何か考えはありますか?

4

2 に答える 2

3

これはおそらく問題です:

$type = filetype($file);
header("Content-type: $type");

説明書より

可能な値は、fifo、char、dir、block、link、file、socket、unknown です。

ヘッダーに表示したくないものです。あなたはおそらく探している:

header('Content-type: application/pdf');
于 2012-04-12T12:36:54.887 に答える
1

あなたはおそらく望んfinfo_file()でいないでしょうfiletype()

于 2012-04-12T12:40:35.273 に答える