我使用下面的代码下载文件(我的文件可以是.pdf或Ms word)。下载任何文件后,该文件出错,无法打开/查看。
$file= "uploads/files/heng_kaknika.docx";
$headers = array('Content-Type: application/pdf', 'Content-Type: application/msword',);
return response()->download($file, 'new_name.docx', $headers);
如何解决这些问题?
答案 0 :(得分:1)
尝试以下代码,从download()
中移除标题并进行检查。由于L5没有标题。见document
$file= "uploads/files/heng_kaknika.docx";
return response()->download($file, 'new_name.docx');