tomfmason Posted August 7, 2006 Share Posted August 7, 2006 I wrote a function that will create a directory and add a file to it. Now I am wondering how I can delete a directory and/or a file. I don't want anyone to write the function for me but rather point me in the right direction i.e.. a link to a relivant section in the manual or an example.Any suggestions would be great.Thanks,Tom Quote Link to comment Share on other sites More sharing options...
Orio Posted August 7, 2006 Share Posted August 7, 2006 For a file- [url=http://www.php.net/manual/en/function.unlink.php]unlink()[/url]For a dir- [url=http://www.php.net/manual/en/function.rmdir.php]rmdir()[/url]Orio. Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 7, 2006 Author Share Posted August 7, 2006 thanks orio. That is exactly what I was looking for.Thanks for the help,Tom Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 7, 2006 Author Share Posted August 7, 2006 I tried using [code=php:0]chdir ($file_system_path);exec ("del *.* /s /q");[/code]And it delted everything in the current directory that I had the file that was running the code. It is a damn good thing that I used a test directory in local host..lolThis is dangerous if you do not know what you are doing.Thanks,Tom Quote Link to comment Share on other sites More sharing options...
zq29 Posted August 7, 2006 Share Posted August 7, 2006 [quote author=tomfmason link=topic=103258.msg411085#msg411085 date=1154944568]I tried using [code=php:0]chdir ($file_system_path);exec ("del *.* /s /q");[/code]And it delted everything in the current directory that I had the file that was running the code. It is a damn good thing that I used a test directory in local host..lolThis is dangerous if you do not know what you are doing.Thanks,Tom[/quote]Indeed. '*.*' will delete all files with an extension as the * character is used as a wildcard, /s flags all sub-directories for deletion, and /q runs in quiet mode - just deleting without prompting. Quote Link to comment 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.