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

BrianA's avatar

Loading An Image From Public Storage - 403 (Forbidden)

Hi,

In one of my blade views, I am trying to display an image by doing:

<img src="<?php echo asset("storage/uploads/iotpark/warranty/$currentFile")?>"></img>

The image is stored in my-website.com>public>storage>uploads>iotpark>warranty.

However, when visiting the page on my browser, the image is not loaded and when inspecting in Chrome's console, the following error is shown:

GET https://my-website.com/storage/uploads/iotpark/warranty/48_00C1D156_1602499479.jpg 403 (Forbidden)

I have run php artisan storage:link in my server's command prompt, and the links were created.

  • This worked well locally and I did not have any errors. Only happening online.

What could it be caused by please?

Thanks! Brian

0 likes
3 replies
BrianA's avatar

@laracoft

Thanks for your reply.

  1. I do have the image file 48_00C1D156_1602499479.jpg in storage/app/public/uploads/iotpark/warranty/

  2. When I tried loading https://my-website.com/uploads/iotpark/warranty/ I got a 404, page does not exist

  3. When checking the permissions for the folders/files on the server hosting the web application, all folders and JPG files have Read and Execute/Search permissions enabled for the 'other users', and Write permissions only enabled for the 'owner'

Thanks

BrianA's avatar
BrianA
OP
Best Answer
Level 1

Hi,

I ended up using a controller (ImageController) and protected route (using middleware) to 'return' the image requested by the view, to the view itself.

This is a different approach from the one above, because I then realized that I needed to have my images accessible only for the users requiring them in the view.. I could not place them in a public directory.

Thanks for your suggestions! :)

Please or to participate in this conversation.