0

I have a laravel 10 app and added an image upload. The image is getting uploaded to

/storage/app/public/user.name/image.jpg

The storage is also linked with: php artisan storage:link. I can see that the storage is linked correctly, since in the /public folder, I can see the link to /storage/app/public

Currently, I can get the image by visiting: http://localhost:8000/storage/user.name/image.jpg

However, I want the image to be visible under: http://localhost:8000/user.name/image.jpg. At least thats how it worked for me in previous laravel apps.

Now for the filesystem. The env var was: FILESYSTEM_DISK=local and I changed it to FILESYSTEM_DISK=public.

I did that because the disks array in the filesystems.php tells me that "public" has the "root" at storage_path('app/public'), which seems right to me.

But I have the feeling that it does absolutely nothing, cause even if I add "s3" in there, I can see the image under the storage URL.

Not sure what to do here?

1
  • 1
    "At least thats how it worked for me in previous laravel apps." This is unlikely; the path you're seeing is the normal one. Why do you care about this, though? Commented Sep 11, 2023 at 21:54

2 Answers 2

0

try to change the url key in disks in config/filesystems.php.

'disks' => [
// ...
        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage', // change this. for example you can omit the '/storage'
            'visibility' => 'public',
            'throw' => false,
        ],
// ...
];
Sign up to request clarification or add additional context in comments.

Comments

-2

For that you'd have to link your public storage path using: php artisan storage:link

This will create a symbolic link, check docs here:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.