xyn Posted September 24, 2006 Share Posted September 24, 2006 Hey Guys,I've got this small idea but i think it's not going to work, butis there a way of using [b]PHP[/b] to [b]DELETE[/b] a [b]FILE[/b]from a directory? Quote Link to comment https://forums.phpfreaks.com/topic/21860-small-question/ Share on other sites More sharing options...
SharkBait Posted September 24, 2006 Share Posted September 24, 2006 YupCheck out unlink() you'll also want file_exists() too to make sure the file is there before you delete (unlink) it. Quote Link to comment https://forums.phpfreaks.com/topic/21860-small-question/#findComment-97619 Share on other sites More sharing options...
xyn Posted September 24, 2006 Author Share Posted September 24, 2006 Would I be able to drop any other queries i have after checking these through php.net? Quote Link to comment https://forums.phpfreaks.com/topic/21860-small-question/#findComment-97620 Share on other sites More sharing options...
SharkBait Posted September 24, 2006 Share Posted September 24, 2006 How do you mean? If you have have any other questions about things? Just ask :) In regards to the unlink() it would work like this:[code]<?php$filename = "myfile.txt";if(file_exists($filename)) { unlink($filename);} else { echo "I cannot find the file to delete.";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21860-small-question/#findComment-97625 Share on other sites More sharing options...
Daniel0 Posted September 24, 2006 Share Posted September 24, 2006 You do not have to check if it exists, just mute the error it would return: [code]@unlink("some_file");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21860-small-question/#findComment-97672 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.