php 下載代碼,在蘋果下不好用!解決方案

來源:互聯網
上載者:User
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
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.