smc Posted January 29, 2007 Share Posted January 29, 2007 Howdy,Okay my question is, as I near the finish line, how to check if files exist, and if they do to delete them.Basically heres my problem. I allow image editation, so basically before I upload the new image I need to find if there is already an image with that name and if so delete it.How would I go about checking to see if a file is in a directory and then deleting it?Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/36130-file-checking-and-deletion/ Share on other sites More sharing options...
spfoonnewb Posted January 29, 2007 Share Posted January 29, 2007 [code]<?php$filename = '/path/to/file/me.ext';if (file_exists($filename)) { echo "The file $filename has been deleted!"; unlink ($filename);} else { echo "The file $filename does not exist";}?> [/code] Link to comment https://forums.phpfreaks.com/topic/36130-file-checking-and-deletion/#findComment-171630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.