PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, March 1, 2022

[FIXED] Laravel Storage File not downloading (File not found)

 March 01, 2022     eloquent, laravel, laravel-5     No comments   

Issue

in my laravel project i have uploads folder from where i am trying to download file.

Folder Hierarchy:

-Project
--Public
---Storage (created using php artisan storage:link)
----uploads
-----file.jpg ( i am trying to download)

Controller:

public function getdata(Request $request)
    {
        return Storage::download('/storage/uploads'.$image_name);
    //image name is file.jpg
      }

Error:

File not found at path: storage/uploads["file.jpg"]

Solution

File not found at path: storage/uploads["file.jpg"]

[] This shows you passing array in path and also / missing after uploads

Your path should be like below

storage/uploads/file.jpg

After above implementation your code would look like

Storage::download('/storage/uploads/'.$image_name);

Get Image from Database

$image_name = Files::select('file_name')->where('custom_code', $request->id)->first();

You can use ->first() and image column accesible using $image_name->file_name

And In your way $image_name[0] access like that.



Answered By - Apurv Bhavsar
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,255,103

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing