请问下怎么解决移动端浏览器直接打开 MP4 格式的文件?
public function getdownload(Request $request)
{
$file = Video::find($request->id);
$extension = pathinfo($file->video_path,PATHINFO_EXTENSION);
$header = [
'Content-Type' => 'application/octet-stream',
'Content-Disposition'=> 'attachment'
];
return Response::download(public_path($file->video_path), time().rand(100000, 999999).'.'.$extension,$header);
}
这是我的下载方法
用手机微信浏览器和谷歌浏览器打开mp4的时候不下载,而是直接打开MP4文件,请问下有什么办法让它强制变成下载吗
html 使用
video
标签就可以了。尝试设置这个响应头: