You're on the right track there, but consider using Spatie's MediaLibrary package - it will take care of many of these decisions for you
Best practice for storing products images
I'm building E-commerce website where every product can have multiple images. I'm looking for an expert opinion on how to store those images? I was thinking of making the product model 'hasMany' images and Images table will contain all images for all products and I will fetch the ones I need according to the product ID.
1- Is there a better way to do it? 2- Do you recommend saving my images to a separate server like AWS and keep my site host small? I mean, is it bad to save them in a relative path within my project?
Do you recommend saving my images to a separate server like AWS and keep my site host small? I mean, is it bad to save them in a relative path within my project?
it depends; you absolutely can get by without S3 or similar if the ecommerce store is relatively small - most VPS will provide you with sufficient storage; but it also carries the risk that you have no redundancy/backups if the server should be lost (it can happen!). Up to you to assess the risk vs. the cost.
Please or to participate in this conversation.