Search code examples
laravellaravel-5laravel-storage

Storage::download working wrong in laravel 5.7


I have a file in path:

app/public/template/templateeSkillsMatrix_Config.docx

and when i use:

return response()->download(storage_path('app/public/template/eSkillsMatrix_Config.docx'));

It is working, but when i use :

return Storage::download(storage_path('app/public/template/eSkillsMatrix_Config.docx'));

It show an error:

File not found at path: E:/project/agl/nav/New folder/DKMH/storage/app/public/template/eSkillsMatrix_Config.docx

I dont know why. I read laravel docs , but i dont understand what is parameter of it.

Please help!


Solution

  • Just like @apokryfos's comment ,Storage::download(..) will automatically use the base storage path so i dont need call storage_path method. I need to call it the following:

    return Storage::download('public\template\eSkillsMatrix_Config.docx');
    

    in this line, i removed storage_path method and delete app/ in path.

    and it is working for me!