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

AbdulBazith's avatar

which location will be secure storage folder or public folder to store image and to accessed by public in laravel?

Guys iam working with online quiz examination.

i need to store question and answer images where i need to store so that public can be used. when i reffered in net most of them suggested to store in storage folder but that doesnt has url.

in my last projects i stored in public folder only. which is better.

$filename = $request->input('ques_no').'-' . $file->getClientOriginalName();
$path = $file->storeAs('QuestionImages', $filename);
dd($path);

i need to store image path in my db and i need to process the image also like resize it.

i tired image intervention to resize and store it in storage folder. but it not worked

i need to riesize it and where to store it to be secure??

Kindly suggest ideas..

0 likes
2 replies
Sinnbeck's avatar

Either should be fine. I prefer to add static images to public (logo, favicon and such) to public and the rest to storage. For it to work you need to use php artisan storage:link. Be aware that it is only the public directory in storage that is accessible from the web.

What do you mean by secure?

AbdulBazith's avatar

@sinnbeck thank you for your response. you are right.

i stored my logo faviicon everything which are static in my public folder.

yes php artisan storage:link i did like this only.

is this correct?? what i mean by secure is is there some other else to store the image with security, which must be used by user but must be secure.

may i know the meaning of this

Be aware that it is only the public directory in storage that is accessible from the web. so what ?? is this right only

ok another doubt

when accessing the image in blade file i used src="{{ asset('QuestionImages/'.$question->ques_image) }}" in my local.

but in my server live i need to mention public folder like this then only its working src="{{ asset('public/QuestionImages/'.$question->ques_image) }}" why?

is this correct??

else if i store it in storage->public->QuestionImage mean then how should use that in my blade file

and i need the path and image name in my db like this

Public/QuestionImage/img1.jpg i dont need to store just the imagee name in db. is this correct.

storing the path with image name is right?? or only the image name is right??

Kindly dont refuge and reply for this please

Please or to participate in this conversation.