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

Ligonsker's avatar

Uploading images and thumbnails

Hello, If I want to allow users to upload photos and videos and there might be a lot of them - and then I want to display thumbnails of them - should I create a thumbnail for each uploaded image/video in a separate folder, or create the thumbnails while loading the images?

The second options doesn't make sense to me if there are many thumbnails so just wanted to make sure

I was thinking about this structure: To have the user uploaded media folder, and inside that folder have another thumbnails folder and store them there

0 likes
2 replies
jlrdw's avatar

First only allow a few at a time to be uploaded, for example 4. You can always have a dialog asking if they want to upload another batch. And I would probably go ahead and create the thumbnails when uploaded, much easier to keep track of things. Just my opinion.

1 like
Ligonsker's avatar

@jlrdw And then have 2 tables - photos and thumbnails and have column in photos with the path/name of the thumbnail the correspond to the photo, with perhaps "belongs to" relationship on the thumbnail and "hasOne" for the photo, or - add a 3rd table that's linking between the photo_id and thumbnail_id?

Please or to participate in this conversation.