0

PHP Web サイトから大きなサイズのビデオをダウンロードしようとすると、18 MB 近くダウンロードした後でダウンロードが停止しました。


次のスクリプトを使用してビデオファイルをダウンロードしています。

@ignore_user_abort();
@set_time_limit(0);
ob_end_clean();

if (!is_file($str_clip_path) or connection_status()!=0) return(FALSE);

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Content-Type: application/octet-stream");
header("Content-Length: ".(filesize($str_clip_path)));
header("Content-Disposition: attachment; filename=".$str_download_filename);
header("Content-Transfer-Encoding: binary");
header("Accept-Ranges: bytes");

if ($fp = fopen($str_clip_path, 'rb')) 
{
    while(!feof($fp)) 
    {
        print(fread($fp, 1*(1024*1024)));
        flush();
    ob_flush();
    }
    fclose($fp);
    exit();
}

私の IIS サーバーでは、特定の変数に対して次の値が設定されています。

memory_limit        512M
max_execution_time          10800
max_input_time      10800
post_max_size       512M
upload_max_filesize     512M

ウェブサイトから大きなビデオ ファイルをダウンロードできるように、上記のスクリプトに必要な変更を加えてください。

KRAさん、よろしくお願いします。

4

1 に答える 1

0

If you using nginx web server you can use x-accel-redirect

于 2012-11-01T10:48:44.933 に答える