how to display the latest photos uploaded by users on my site.i don't know how to do it. I need help from you and because IAM starting, i can't display any code for that.
2 Answers
if you have a database: you have to write your sql (something like: select * from user_pictures ... limit 10) and iterate that result to display the pictures. if you only have uploaded pictures in a folder, scandir should do it. How to get the newest file in a directory in php

- 1
It depends on how you store the uploaded photos . Anyway I did it before like this:
1- Convert the image to jpeg or any thing , in ALL cases . this will prevent users from uploading non images or codes or files named as image.
2- change the name of the image to a combination of timestamp and user id and store it in a specific folder.
3- insert in database the following info: new name of this image, old name , upload date , and user id who uploaded
I can then select the last uploaded from database or select by user id or .. you know the options are limitless
Be careful for the old name of the photo for SQL injection

- 445
- 4
- 13