Image path in database vs intelligent folder structure -
assuming want safe 1 profile picture each user of system. better save path image in database or rely on intelligent folder structure like
/images/users/user1.png
and access image directly?
what if have more 1 picture per user? practice?
/images/user1/pic1.png
so question is, why save picture's path , waste space when know pictures without db queries?
this general question apart technologies.
it's better assume each user have more 1 picture, if you're absolutely sure of otherwise now.. 2 ways go it:
each user have folder pictures.
/path/user1/img1.jpg
,/path/user1/im2.gif
all pictures in same folder,
username
prefix of filename/path/user_pics/user1_img1.jpg
,/path/user_pics/user2_img3.gif
personally, prefer former.
in cases, won't need store full path of picture in database.. storing image content-type (which determines extension) , filename enough. gives more freedom machine serving image itself.
Comments
Post a Comment