gple Posted May 28, 2007 Share Posted May 28, 2007 If I have the URL to an image in my directory. How can I use PHP to delete that file? Link to comment https://forums.phpfreaks.com/topic/53280-delete-file-from-directory/ Share on other sites More sharing options...
MadTechie Posted May 28, 2007 Share Posted May 28, 2007 unlink Link to comment https://forums.phpfreaks.com/topic/53280-delete-file-from-directory/#findComment-263289 Share on other sites More sharing options...
redarrow Posted May 28, 2007 Share Posted May 28, 2007 post more code as unlink can be quit a tricky statement to work with ok. Link to comment https://forums.phpfreaks.com/topic/53280-delete-file-from-directory/#findComment-263291 Share on other sites More sharing options...
chronister Posted May 28, 2007 Share Posted May 28, 2007 $file='/path/to/your/file'; if(unlink($file)) { echo 'File Deleted'; } else { echo 'File could not be deleted'; } I use this as well. I grab the filename from MySql, and use the results to set the path. It works well. Link to comment https://forums.phpfreaks.com/topic/53280-delete-file-from-directory/#findComment-263446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.