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

umerhassan's avatar

Best way to store product images

I am creating an eCommerce solution in laravel and I need to store product Image, I need suggestions what would be the best way to store product images? Is local storage where files are hosting or any other cloud storage would be better?

0 likes
7 replies
umerhassan's avatar

I tried both s3 and local but S3 is talking too much time. and sometime it says 504 gateway time out.

1 like
goatshark's avatar

@UMERHASSAN I did this recently. It was yesterday-ish. I used Spatie's Laravel Medialibrary

https://docs.spatie.be/laravel-medialibrary

There are some really handy methods for treating an object as having just one single image attached to it. I also think that it handles the file storage / destination work very well.

1 like
umerhassan's avatar

Thank you @goatshark for reply actually I am handling s3 perfectly. But the issue I am facing with s3 uploading. It is taking too much time. suppose one image of 800kb takes about 1.5 or 2 mins to upload. Thats why I am asking the best practice for image storing.

Is there any other thing that can be creating issue while uploading, like forge, nginx ??

1 like
goatshark's avatar

@umerhassan The Internet connection I'm on most of the time has very limited upload. It sounds like your's does/might too. If you just save locally, does it save almost immediately? Just trying to determine if the upload speed is your bottleneck. If it is, you could save locally in development and save to s3 in production. Or save locally and fire an Event/Listener or Job to do the work of talking to s3 (or anyone out in the network).

1 like
umerhassan's avatar

Yea same here locally it save almost immediately. But If we switch to s3 it slows down. I was curious that is there anything wrong with my process of uploading.

1 like

Please or to participate in this conversation.