Jump to content

Archived

This topic is now archived and is closed to further replies.

tomfmason

Delete a file?

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
thanks orio. That is exactly what I was looking for.


Thanks for the help,
Tom

Share this post


Link to post
Share on other sites
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..lol

This is dangerous if you do not know what you are doing.

Thanks,
Tom

Share this post


Link to post
Share on other sites
[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..lol

This 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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.