.mp4ファイルをダウンロードしようとしています。 (約1.3GBサイズ)。私は、以下の使用してい : PHPファイルからの強制ダウンロード
<?php
$path = "video.mp4";
header('Accept-Ranges: bytes'); // For download resume
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="'.basename($path).'"');
header('Content-Length: ' . filesize($path)); // File size
header('Content-Transfer-Encoding: binary'); // For Gecko browsers mainly
header('Content-Type: application/octet-stream');
header('Expires: 0');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT');
header('Pragma: no-cache');
ob_clean();
flush();
readfile($path);
私は私のPHPファイルを開き、Firefoxは「保存する」メニューがポップアップ表示されます。サイズは正しく見えます。 私はデスクトップに[名前を付けて保存]を押します。最終的にダウンロードされるファイルは、400MB(330,463,440)くらいのランダムなサイズで表示されます。
レスポンスヘッダは、次のとおりです。
Connection: Keep-Alive
Content-Disposition: attachment; filename="//www.frederikspang.dk/elevgallavideo.mp4"
Content-Length: 1422778850
Content-Type: video/mp4
Date: Sun, 30 Jun 2013 22:12:30 GMT
Keep-Alive: timeout=10, max=50
Pragma: public
Server: Apache
content-transfer-encoding: binary
実行制限時間を過ぎている可能性があります。ダウンロードはいつも同じ時間後に停止しますか? –
再開可能なファイルのダウンロードにはこれよりも多くのコードが必要です。 'Accept-Range 'を削除する必要があります。参照:http://stackoverflow.com/questions/157318/resumable-downloads-when-using-php-to-send-the-file –
実際に出力バッファリングを使用していますか?そうでなければ、おそらくob_clean()とflush()は必要ありません。なぜなら、readfileコマンドはクライアントに直接データを出力するからです。 – dethtron5000