Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]rmdir
peter13135
post
Post #1





Grupa: Zarejestrowani
Postów: 1 447
Pomógł: 191
Dołączył: 26.03.2008

Ostrzeżenie: (0%)
-----


mam folder o nazwie $folder

chcę go skasować w ten sposób
  1. <?php
  2. rmdir($folder);
  3. ?>


jednak wywala mi taki błąd

Warning: rmdir(5161 in /virtual/d/a/dark-knights.ugu.pl/zip/index.php on line 99
Go to the top of the page
+Quote Post
Spirit86
post
Post #2





Grupa: Zarejestrowani
Postów: 607
Pomógł: 23
Dołączył: 8.09.2004
Skąd: Wrocław

Ostrzeżenie: (0%)
-----


Cytat
Katalog musi byc pusty, i stosowne uprawnienia muszą na to pozwalać.





funkcja:
  1. <?php
  2. function usunKatalog($path){
  3. $return = true;
  4. if (file_exists(dirname($path))) {
  5.    foreach (new DirectoryIterator(dirname($path)) as $file) {
  6.        if (true === $file->isFile()) {
  7.            if(!unlink($file->getPathName())) $return = false;
  8.        }
  9.    }
  10.    if(!rmdir(dirname($path))) $return = false;
  11. }
  12. else $return = false;
  13.  
  14. return $return;
  15. }
  16. ?>


użycie:
  1. <?php
  2. usunKatalog('www/katalog/');
  3. ?>


Ten post edytował Spirit86 12.10.2008, 12:28:13
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 22:44