You cannot access image or file directly from storage/app as a url, if u want to access the image from storage folder use public disk or save the image in public folder.
Jan 10, 2018
5
Level 13
Cannot display image from local storage
Hi. I can't for the life of me retrieve and display an image from local storage. It all worked using
I've set up the simlink and its set to local in the config/filesystem.
The files are saving to the correct place and when i right click the image, it is pointing to the correct place but it still shows 404 error.
I've tried a handful of different locations including '/storage/app', '/storage/' and so on but still nothing.
Upload Code in Controller
$file = $request->file('job_image');
$path = $file->hashName('/users/' . \Auth::id() . '/jobs/' . \Carbon\Carbon::now()->toDateString());
$image = Image::make($file);
$image->fit(1200, 800, function ($constraint) {
$constraint->aspectRatio();
});
Storage::put($path, (string) $image->encode());
This saves the path as /users/2/jobs/2018-01-11/5r77oB7xhXSSsg81pIGJo5yN9g8yiqKHxtkYT20f.jpeg in the db...
VIew:
<img class="job-card" src="{!! Storage::disk('local')->url($job->img_path) !!}" alt="{{ $job->category['name'] }}">
Any ideas on what i'm doing wrong?
Please or to participate in this conversation.