Jump to content


Photo

Delete a file?


  • Please log in to reply
4 replies to this topic

#1 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 07 August 2006 - 09:13 AM

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

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 07 August 2006 - 09:18 AM

For a file- unlink()
For a dir- rmdir()

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 07 August 2006 - 09:21 AM

thanks orio. That is exactly what I was looking for.


Thanks for the help,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#4 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 07 August 2006 - 09:56 AM

I tried using
chdir ($file_system_path);
exec ("del *.* /s /q");

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

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#5 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 07 August 2006 - 10:28 AM

I tried using

chdir ($file_system_path);
exec ("del *.* /s /q");

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

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users