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

codemode's avatar

Path to file stored in storage

Sorry for asking a question that has been asked several times before, but i could not solve my problem yet.

I'm trying to simply save a picture into my local storage, and then to access it's URL.

Here is the controller :

public function uploadProfilePic(Request $request)
    {
      $user_id = Auth::user()->id;
      $path = $request->file('profilePic')->store('profilePics/'.$user_id);
    }

The $path above returns a value like : profilePics/1/xGZJVdD3cSoyawPe8ZkZmSNyuKoE8KsTG1UZHoEW.jpeg

And the file is stored as : storage/app/profilePics/1/xGZJVdD3cSoyawPe8ZkZmSNyuKoE8KsTG1UZHoEW.jpeg

1.) Is the above, the right place to store public images, or should they be placed inside storage/app/public

2.) What is the file URL? I tried : www.domain.com/storage/app/profilePics/1/xGZJVdD3cSoyawPe8ZkZmSNyuKoE8KsTG1UZHoEW.jpg , www.domain.com/storage/profilePics/1/xGZJVdD3cSoyawPe8ZkZmSNyuKoE8KsTG1UZHoEW.jpg , www.domain.com/profilePics/1/xGZJVdD3cSoyawPe8ZkZmSNyuKoE8KsTG1UZHoEW.jpg

But none of them seem to work. Filesystems.php configuration is kept default.

Thanks.

0 likes
7 replies
jlrdw's avatar

You can make a folder under assets. I always just do

<img src="<?php echo asset('assets/upload/imgdogs') . '/' . $row->dogpic; ?>" alt="" class="image">

Look at url helpers in the docs.

Snapey's avatar

yes, the file should be in the storage/app/public folder, as long as you use the artisan command to make the symlink.

Change the store method $path = $request->file('profilePic')->store('profilePics/'.$user_id,'public');

Then the URL to the file will be '/storage/'.$path;

codemode's avatar

Hi @jlrdw , do you mean store the file under resources/assets instead of the storage/ folder?

codemode's avatar

Hi @Snapey , adding 'public' does save the file under the public folder.

But, '/storage/'.$path; would be www.domain.com/storage/profilePics/1/xGZJVdD3cSoyawPe8ZkZmSNyuKoE8KsTG1UZHoEW.jpg , isn't it? That does not work :(

I did not get the "artisan command to make the symlink." part

Snapey's avatar
Snapey
Best Answer
Level 122

If your site is served correctly then the storage folder is not accessible to the outside world

to publish the Storage public folder you run php artisan storage:link

This creates a symbolic link for youwhich makes storage/app/public appear as public/storage

https://laravel.com/docs/5.6/filesystem#the-public-disk

Please or to participate in this conversation.