Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> php i usuwanie folderów, problem :/
Edd_s
post
Post #1





Grupa: Zarejestrowani
Postów: 54
Pomógł: 0
Dołączył: 5.04.2005

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


w php jest taka funkcjia: rmdir(nazwa) jest fajna bo usuwa katalog na serwerze o podanej nazwie, ale katalog musi być pusty, no właśnie w tym problem, czy jest jakaś funkcja kasująca folder z zawartością czy są jakieś inne sposoby albo ktoś ma jakiś pomysł(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/dry.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Speedy
post
Post #2





Grupa: Zarejestrowani
Postów: 651
Pomógł: 28
Dołączył: 4.12.2004

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


  1. <?php
  2. /**
  3.  * Delete a file, or a folder and its contents
  4.  *
  5.  * @author Aidan Lister <aidan@php.net>
  6.  * @version  1.0.2
  7.  * @param  string  $dirname Directory to delete
  8.  * @return bool  Returns TRUE on success, FALSE on failure
  9.  */
  10. function rmdirr($dirname)
  11. {
  12. // Sanity check
  13. if (!file_exists($dirname)) {
  14. return false;
  15. }
  16.  
  17. // Simple delete for a file
  18. if (is_file($dirname)) {
  19. return unlink($dirname);
  20. }
  21.  
  22. // Loop through the folder
  23. $dir = dir($dirname);
  24. while (false !== $entry = $dir->read()) {
  25. // Skip pointers
  26. if ($entry == '.' || $entry == '..') {
  27. continue;
  28. }
  29.  
  30. // Recurse
  31. rmdirr(&#092;"$dirname/$entry\");
  32. }
  33.  
  34. // Clean up
  35. $dir->close();
  36. return rmdir($dirname);
  37. }
  38.  
  39. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Closed TopicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 18.01.2026 - 20:33