Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why my laravel development server doesnt serve files under public folder?

I am using Spatie for images. I have the current public definition on my filesystems.php as:

'public' => [
    'driver' => 'local',
    'root'   => public_path().'/media',
    'url' => env('APP_URL').'/public/media',
    'visibility' => 'public',
]

Which gives me links as
http://localhost:8000/public/media/3/profile_3.png

When I enter this URL into the browser, the Laravel server responds with 404 even though the profile_3.png file is in the public/media/3/ directory on the server.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What could be the problem in my case? thank you.

I tried different combinations, and it still doesn’t work.

>Solution :

Update filesystems.php.

'public' => [
    'driver' => 'local',
    'root' => public_path().'/media',
    'url' => env('APP_URL').'/media', // Remove '/public' from the URL
    'visibility' => 'public',
]

Then clear the config cache after making changes to filesystems.php:

php artisan config:cache

Then try accessing the image at:

http://localhost:8000/media/3/profile_3.png

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading