Storing User-uploaded Images
Posted
by
Nyxynyx
on Pro Webmasters
See other posts from Pro Webmasters
or by Nyxynyx
Published on 2011-06-30T10:05:24Z
Indexed on
2011/07/01
16:31 UTC
Read the original article
Hit count: 271
What is the usual practice for handling user uploaded photos and storing them on the database and server?
For a user profile image:
- After receiving the image file from user, rename file to
<image_id>_<username>
- Move image to
/images/userprofile
- Add img filename to a table
users
containing their profile details likefirst_name, last_name, age, gender, birthday
For a image for a review done by user:
- After receiving the image file from user, rename file to
<image_id>_<review_id>
- Move image to
/images/reviews
- Add img filename to a table
reviews
containing their profile details likereview_id, review_content, user_id, score
.
Question 1: How should I go about storing the image filenames if the user can upload multiple photos for a particular review? Serialize?
Question 2: Or have another table review_images
with columns review_id, image_id, image_filename
just for tracking images? Will doing a JOIN
when retriving the image_filename
from this table slow down performance noticeably?
Question 3: Should all the images be stored in a single folder? Will there be a problem when we have 100K photos in the same folder?
Is there a more efficient way to go about doing this?
© Pro Webmasters or respective owner