Download File
I have a page in which I have a download button that shou
From google chrome help center
If you try to download a file and it doesn’t work, first try to fix the error with these troubleshooting steps:
Make sure your internet connection is working normally. If your internet connection is unstable, learn how to fix internet stability issues.
. Chrome will automatically resume the download. You can also resume the file download by clicking the Down arrow Down Arrow and then Resume or More More and then Resume.
Try to download the file later.
Contact the website owner.
If 1 and 2 not work. and you trying with other browsers then the problem is in your file and server.
You can fix it by checking file_exists and send file by Yii2 sendFile. see example:
$file_path = '/route/to/path/file.xlsx';
if (file_exists($file_path)) {
return Yii::$app->response->sendFile($file_path);
}else{
return 'file not found';
}
you can use this code in any controller .