php 下載代碼,在蘋果下不好用!
PHP code
$file = fopen($filename, "r ");Header( "Content-type: application/octet-stream ");Header( "Accept-Ranges: bytes ");Header( "Accept-Length:".filesize($filename));Header( "Content-Disposition:attachment;filename= ".$filename);echo fread($file,filesize($filename));fclose($file);
剛開始用的這個,直接就把內容輸出到頁面上了。後來又找了個函數
PHP code
function download_file($archivo, $downloadfilename = null) { if (file_exists($archivo)) { $downloadfilename = $downloadfilename !== null ? $downloadfilename : basename($archivo); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . $downloadfilename); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($archivo)); ob_clean(); flush(); readfile($archivo); exit; } }
效果還是一樣,求高手解決!
下面是我和一個人的對話:
蘋果的介面直接給資源地址就行了
追問
就是說 直接將連結地址設為檔案的地址,對吧! 我試過了,不會彈出下載框,也是直接輸出要頁面!
回答
我剛問過手機組,蘋果的作業系統跟windows不同,沒有許可權下載東西,即使可以下載東西,蘋果也不會分配給你儲存空間去儲存資源。蘋果只會識別應用,並且給應用程式指派一定的空間儲存,若要讓蘋果下載資源,請走應用渠道。
追問
但是我平時有用蘋果的作業系統下載東西啊! 就是在網上點下載的時候會彈出下載提示框的! 但是不確定該網站的伺服器用的是什麼作業系統。 你的意思是不是,蘋果的伺服器不提供下載? 那麼是不是所有拿蘋果當伺服器的網站都沒有下載的功能?
------解決方案--------------------
探討
PHP code
$file = fopen($filename, "r ");
Header( "Content-type: application/octet-stream ");
Header( "Accept-Ranges: bytes ");
Header( "Accept-Length:".filesize($filename));
Header( "Content……
------解決方案--------------------
探討
瀏覽器可以下載 http://www.duote.com/soft/2054.html 這個頁面上點擊下載可以彈出下載框!
------解決方案--------------------
這些參數看看有用沒?
http://apps.hi.baidu.com/share/detail/35570157
http://blog.csdn.net/starzxf/article/details/6746876
http://iask.sina.com.cn/b/6263205