php文件下载脚本;不能使用iOS7设备


php file download script doesn't work with iOS7 device?

我有下面的php脚本来触发自动下载。

<?php
    ob_start();
    $file = 'sample.jpg';
    if (file_exists($file)) {
        header('Content-Description: File Transfer');
        header('Content-Type:  application/octet-stream');
        header('Content-Disposition: attachment; filename='.basename($file));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        ob_clean();
        flush();
        readfile($file);
        exit;
    }
?>

http://toasterlab.net/liese/

它在桌面和我的安卓手机上都能正常工作,但在我的iPad和iPhone上却不能。

我该怎么做才能让它在iPad&iphone?

谢谢。

试着注释掉设置内容长度的行,如下所示:

    //header('Content-Length: ' . filesize($file));

我还没有深入研究,但现在这对我在iPad iOS 7.0.4 上有效