Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bitzsalex's avatar

Storage::url() not working

I used Storage::url() to get the path to the image. I have logo_path stored in the database and I wanted to print the logo. The funniest part is Storage::url($school->logo_path) won't display the image which is printed in the src attribute of an img tag but if I dd(Storage::get($school->logo_path) I get the binary data of an image, even the code below works completely fine.

if (Storage::exists($school->logo_path)) {
	Storage::delete($school->logo_path);
}

I created symlink with php artisan command, I tried url($school->logo_path), asset($school->logo_path) no change at all.

<img src="{{ $school->logo_path ? Storage::url($school->logo_path) : url('/img/default-school.jpg') }}" alt="{{ $school->name . ' logo' }}"> // not displaying the image

Anyone with help, please?

Here is the code to store the path in the DB

if ($request->hasFile('logo_path')) {
    if ($school && Storage::exists($school->logo_path)) {
    	Storage::delete($school->logo_path);
    }

    $extension = $request->logo_path->extension();
    $fileName = implode('_', explode(' ', $request->name));
    $fileName = $fileName . "_logo." . $extension;
    $path = $request->logo_path->storeAs('public/school-logos', $fileName);
            
	return $path;
}

I am on Windows 10 Machine, PHP version 7.4, and Laravel Ver 8.12

0 likes
8 replies
jlrdw's avatar
jlrdw
Best Answer
Level 75

Unless the symlink didn't work, because asset helper is working for me.

bitzsalex's avatar

@jlrdw the site I am working on works perfectly fine locally but I uploaded it to the live server but the link is broken again, and I use the two methods which I found googling but none of them work. Do you have any solution?

The methods I use, SSH command: ln -s ./domains/.../newsite/storage/app/public public_html/storage here I tried the following as well ln -s ./domains/happyschools.co.uk/newsite/storage public_html/storage

Route method: Route::get('/foo', function () { Artisan::call('storage:link'); });

My folder structure is as follows: mydomain.com newsite // all my laravel files and directories except public directory public_html // my laravel public directory goes in here

Snapey's avatar

as posted on a similar question earlier today

Have you viewed the browser source and checked the paths being specified ?

Have you looked where in the file system these files are actually saved to?

Have you checked the format of the file name in the database? Is it correctly stored?

Have you checked that you are using the correct column name in the view?

bitzsalex's avatar

Thanks all for your help!

But after hours and hours of trial, I deleted the previous link found in the public directory and run a new storage:linkcommand and it worked perfectly fine.

jlrdw's avatar

That's what I meant when I said:

Unless the symlink didn't work

Please or to participate in this conversation.