Saturday, 15 January 2011

Delete files with PHP -


I have a list of file paths I want to delete. I have placed the file path in a sandext file of the server path. For example:

files_to_be_removed.txt

  /path/to/bad/file.php / path / to / another / bad / File .php   

In the same directory, I have another file:

remove.php

  $ handle = @ fopen ("files_to_be_removed.txt", "r"); If ($ handle) {'$ buffer = fgets (handles, $ 4096))! == wrong) {if' (unlink ($ buffer)) $ buffer 'echoed'. '; } Fclose ($ handle); }   

When I run my script, there is no output. Simply, the files in the list are not being deleted. Why is it like this?

  $ files = file ('files_to_be_removed.txt', FILE_IGNORE_NEW_LINES); Foreign Currency ($ file $ files) {if (@inlink ($ file)) {echo $ file, 'deleted', PHP_EOL; } And {$ error = error_get_last (); Could not 'echo', $ file, ':', $ error ['message'], PHP_EOL; }}    

No comments:

Post a Comment