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? Quote 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 Quote 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. Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/53280-delete-file-from-directory/#findComment-263446 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.