我在<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;
?>