2012-04-23 25 views
1

使用X-Sendfile發送文件而不是讀取文件。該腳本處理此,被命名的download.php和包含此:使用X-Sendfile下載文件的文件名

$video_file = '/path/to/file/file.mp4'; 
header('X-Sendfile: '.$video_file); 
header('Content-Type: video/mp4'); 
header('Content-Disposition: attachment; file=\"file.mp4\"'); 
exit(); 

但問題是,下載的文件總是被命名爲「的download.php」(爲155Mb),我想下載它命名爲文件.MP4。我曾嘗試過幾件事:

header('Content-Disposition: attachment; file="file.mp4"'); 
header('Content-Disposition: attachment; file=file.mp4'); 

和其他所有可能性,但仍下載文件爲download.php。

我htaccess文件包含:XSendFile在

回答

1

你發送一個不正確的報頭。文件名屬性被稱爲filename,不name

header('Content-Disposition: attachment; filename="file.mp4"'); 

用於報頭的詳細描述參見RFC2616

+0

該死!什麼錯誤。謝謝! – felixjet 2012-04-23 08:59:16

+0

完成;)在社區的新手,正在尋找接受按鈕 – felixjet 2012-04-23 09:10:24