Looking for logic on a file upload and if statement

I’m working on a profile update page for users. I give users the option to upload a picture (just one). if they already have a picture uploaded in file I want to give them the ability to delete their old picture and upload a new one in its stead. Or simply cancel the upload of their new picture they are trying to upload if they wish. Is there a way to do this while only using php? I don’t want to use javascript or ajax or jquery, I want to stick to php even if it is not the most efficient or slower or whatever. I just can’t be bothered to learn Javascript at the moment.

That is simple, just check if there is already path to picture stored in database when you’re uploading new one. If so, then delete old picture and save new path instead. Also you can add a checkbox labeled “Delete picture” in your form when user edits profile with picture uploaded, and delete picture file if that checkbox was checked. That will allow users to remove pictures without uploading new ones.

No, you can’t do it without javascript

thank you, I kind of figured javascript was required but was hoping I could get away without it.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.