0

<a href>ビデオ ファイル (mp4) を指すページにリンクがあります。訪問者がリンクをクリックすると、ビデオ ファイルがブラウザ ウィンドウで開きます。

ファイルをダウンロードする場合は、「右クリック」してから「名前を付けてリンクを保存...」する必要があります。

ワンクリックでファイルがダウンロードされるように(右クリックする必要がないように)したいのです。

編集:ここで何が問題なのですか?

<?php
    header('Content-Description: File Transfer');
    header('Content-Type: video/mp4');
    header('Content-Disposition: attachment; filename=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;
?>
4

1 に答える 1

4

Content-Dispositionヘッダーを に設定しattachmentます。例えば:

Content-Disposition: attachment; filename=lolcats42.mp4
于 2012-02-06T18:17:43.237 に答える