mysql - Access folder and select filename using PHP -


i have written code, user selects profile picture , picture stored in localhost/user/$username/photos/photo1.gif.

after that, assigned filename (photo1.gif) session variable can display php scripts. working fine. can display picture in every php script accessing session variable.

the problem have when trying login login page: in login page connect database, retrieve email , password, check them , if ok redirect user home.php. problem user's photo not linked email cannot know filename of photo. thing know sure directory (because can retrieve username database well).

lets user has uploaded 4 photos (photo1, photo2, photo3, photo4 - photo4 uploaded last). makes sense using photo4 profile picture. there way me access folder , retrieve filename of picture uploaded last?

also, general question, better, store photos(or files) in database or server?

a few options:

it 'better' create photo table , store user_id , photo location in table. storing actual photo in table blob not recommended.

alternatively, avoid more tables, rename photos

username_photo1.jpg username_photo2.jpg username_photo3.jpg 

and can retrieve largest of them.

finally, option file creation date of photos in directory , take recent photo.

see getting filenames of files in folder


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -