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
ebe
post
Post #2





Grupa: Zarejestrowani
Postów: 150
Pomógł: 1
Dołączył: 23.01.2004

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


unlink nie skasuje katalogu z plikami.

Do autora topicu, czasem bardzo owocne jest czytanie komentarzy w manualu. Jest tam piękny przykład, nie jestem jego autorem:


  1. <?
  2. function rmdirRecursive($path,$followLinks=false) {
  3.  
  4.  $dir = opendir($path);
  5.  while ( $entry = readdir($dir) ) {
  6.  
  7.  if ( is_file( &#092;"$path/$entry\" ) || ((!$followLinks) && is_link(\"$path/$entry\")) ) {
  8.  echo ( &#092;"unlink $path/$entry;n\" );
  9.  // Uncomment when happy!
  10.  //unlink( \"$path/$entry\" );
  11.  } elseif ( is_dir( &#092;"$path/$entry\" ) && $entry!='.' && $entry!='..' ) {
  12.  rmdirRecursive( &#092;"$path/$entry\" );
  13.  }
  14.  }
  15.  closedir($dir);
  16.  echo &#092;"rmdir $path;n\";
  17.  // Uncomment when happy!
  18.  // return rmdir($path);
  19. }
  20. ?>


Ten post edytował ebe 7.04.2005, 22:17:15
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: 16.01.2026 - 22:38