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

joaonascimento's avatar

Some images give 404 error

Good morning, I have a strange problem here. I have a folder with multiple images and I have an if condition to check if the image exists. But when I generate the public link (to send via api for an integration) in some images it gives 404 error.

if ( Storage::disk('local')->exists('public/imagens/'.$product->referencia.'.jpg') ) { $image_src = URL::to('/').Storage::disk('local')->url('public/imagens/'.$product->referencia.'.jpg'); }

Can someone help me figure out what's going on?

0 likes
1 reply
vincent15000's avatar

Can you write your code between backticks please ?

About your problem, if some images load correctly and some others generate an error, I would first check the referencia value in the database.

Please or to participate in this conversation.