1

I cannot download my file from the local storage using php (laravel version 5.3). i've done all the research and follow everything still download won't work. no errors but no download happens.

Route::post('api/downloadfile', function($file_name = 'ExportFile.xlsx')
{   
     // file exist on this file path ..\storage\exports\ExportFile.xlsx

     $path = storage_path().'/'.'exports'.'/'.$file_name;

     if (file_exists($path)) {
         ob_end_clean();
         ob_start();             
         return Response::download($path);
     }
});

and i also even tried my return as and still didn't work:

 return response()->download($file);

here is my Response Header:

 Accept-Ranges:none
 Cache-Control:public
 Connection:close
 Content-Disposition:attachment; filename="ExportFile.xlsx"
 Content-Length:12328
 Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
 Date:Mon, 26 Feb 2018 07:53:32 GMT
 ETag:"da39a3ee5e6b4b0d3255bfef95601890afd80709"
 Host:localhost:8000

and i even modified the headers.

lukas
  • 7
  • 3
  • check this post.. https://stackoverflow.com/questions/43315857/cannot-download-file-from-storage-folder-in-laravel-5-4 – Bilal Ahmed Feb 26 '18 at 08:14
  • Hi @BilalAhmed, I have tried it already i've got no error but when i check the response: PKÒZLGD²Xð[Content_Types].xml­MNÃ0÷"ò%nY vAa (0ö¤±êØgúw{&i@ÕnbEö{ßøyìÑdÛ¸l mð¥×ÁX¿(ÅÛü)¿òF¹à¡;@1_æ»±Øc)j¢x/%êEày¦ and i even remove the space of php – lukas Feb 26 '18 at 08:35
  • this case is closed. – lukas Feb 28 '18 at 02:44

0 Answers0