Jump to content

Delete a file?


tomfmason

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
Link to comment
https://forums.phpfreaks.com/topic/16773-delete-a-file/
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
Link to comment
https://forums.phpfreaks.com/topic/16773-delete-a-file/#findComment-70557
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.
Link to comment
https://forums.phpfreaks.com/topic/16773-delete-a-file/#findComment-70569
Share on other sites

Archived

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

×
×
  • Create New...

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.