我正在使用X-Sendfile发送文件,而不是readfile。处理此问题的脚本名为download.php,其中包含以下内容:
$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),而我想将其命名为file.mp4。我尝试了几种方法,比如:
header('Content-Disposition: attachment; file="file.mp4"');
header('Content-Disposition: attachment; file=file.mp4');和所有其他可能性,但仍然以download.php格式下载文件。
我的htaccess文件包含: XSendFile On
发布于 2012-04-23 16:02:19
您发送的报头不正确。filename属性称为filename,而不是name
header('Content-Disposition: attachment; filename="file.mp4"');有关标头的详细说明,请参阅RFC2616。
https://stackoverflow.com/questions/10276248
复制相似问题