Johnson Johnson - 3 years ago 144
PHP Question

Replace image(s) with another image(s) from server

For examples, You can upload profile avatar to your profile. I want to remove the previous one the user had.

So before the query, where it changes the column "avatar" with the newfile2.jpg i would like to get the old file newfile1.jpg, and remove the previous image from the server.

How can I remove an image from the server?

Answer Source

You could just use a naming convention. Something like:

<user_id>_avatar.jpg

so when the user uploads the new avatar image it just overwrites the old one.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download