I use below code to download the files (my file can be .pdf or Ms word). After downloading any of the files, the file is error and can't be opened / view.
$file= "uploads/files/heng_kaknika.docx";
$headers = array('Content-Type: application/pdf', 'Content-Type: application/msword',);
return response()->download($file, 'new_name.docx', $headers);
How can I fix these problems?
Try below code, remove header from download()
and check it. As L5 work without header. See document
$file= "uploads/files/heng_kaknika.docx";
return response()->download($file, 'new_name.docx');