2013-12-14 30 views
0

我有以下的PHP腳本來觸發auto downlad。php文件下載腳本不適用於iOS7設備?

<?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/

它工作正常的桌面,我的Android手機,但不是我的iPad和iPhone。

我該怎麼做才能讓它在iPad上工作& iphone?

謝謝。

+0

我認爲這是一個iPhone瀏覽器的問題,並沒有太多的代碼..有人證明我,如果我錯了。 –

+0

但不僅safari,iPad上的鉻也不起作用 –

+0

iOS7不允許自動執行。您需要爲其分配一個點擊事件。 – Vector

回答

1

嘗試註釋掉你設置內容長度的線,像這樣:

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

...我還沒有更深入地挖掘,但現在這的工作對我的iPad等iOS 7.0.4

+0

這個解決方案對我來說也適用於相關的問題。該腳本適用於除Safari之外的任何瀏覽器。刪除Content-Length標題修復了它,它現在似乎適用於所有瀏覽器。 (警告 - 我只執行有限的測試,刪除內容長度可能會有一些負面影響) –

相關問題