Home » Php » Laravel 5.6 Storage::download file not found

Laravel 5.6 Storage::download file not found

Posted by: admin June 30, 2018 Leave a comment

Questions:

I’m using Laravel 5.6, filesystems.php config default.

When file is uploaded I have record in my DB with path column where paths is recorded like – posts/p4NbvgcxHFcT10TwbS2UUJrajifPcqpN3i7iSyyk.png

Symlink was created and files stored in public dir.

 $path = $file->store('posts', 'public');

This path is recorder to DB, if I want to show e.g. image, I can access it by:

{{ asset('/storage/'.$file->path) }}

But when I try to force download it get exception – FileNotFoundException
File not found at path:

File download method:

  public function downloadFile($id){
    $file = File::find($id);

    //return Storage::download(storage_path()."/app/public/".$file->path, $file->original_name);
    //also tried like this
    return Storage::download(asset('storage/'.$file->path), $file->original_name);
}

App running on Windows OS

Answers: