Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Sprawdzenie czy istnieje taki folder
Forum PHP.pl > Forum > Przedszkole
ZRV
  1. <?php
  2. $katalog = $_GET['katalog'];
  3.  
  4. if(!isset($katalog) )
  5. $katalog = "_ZGK";
  6.  
  7. if ($otwiera = opendir($katalog))
  8. {
  9.  $skad = substr($katalog, (strrpos(dirname($katalog."/."),"/")+0));
  10.  print "Aktualny katalog: ".$skad."<br>************************<br>";
  11.  print "Sciezka: ".dirname($katalog."/.")." <br>************************<br>";
  12.  $i=0;
  13.  while (false !== ($file = readdir($otwiera)))
  14.  {
  15. if ($file != "." && $file != "..")
  16. {
  17.  $fName = $file;
  18.  $file = $katalog.'/'.$file;
  19.  $tablica[$i][0] = $fName;
  20.  $tablica[$i][1] = $file;
  21.  $i++;
  22.  
  23. }
  24.  }
  25.  
  26.  @rsort( $tablica );
  27.  
  28.  for ( $a=; $a<count($tablica) ; $a++ )
  29.  {
  30. $fName = $tablica[$a][0];
  31. $file = $tablica[$a][1];
  32.  
  33. // echo( $file . "<br>" );
  34.  
  35. if ( is_file( $file ) ) // jeśli plik
  36.  print "<img align='absmiddle' src='60.jpg'width='32' height='32'><a href='".$file."'>".$fName."</a>" . filesize($file) . " B<br>";
  37. elseif ( is_dir($file) ) // jesli folder
  38.  print "<img align='absmiddle' src='136.jpg'width='32' height='32'> <a href='index.php?katalog=".$file."'>".$fName."</a><br>";
  39.  
  40.  }
  41.  
  42.  
  43.  $up = substr($katalog, 0, (strrpos(dirname($katalog."/."),"/")));
  44.  if ( $up != "" )
  45.  {
  46. print "<img align='absmiddle' src='wrooc.jpg'width='32' height='32'><a href='index.php?katalog=$up'> Cofnij katalog</a><br>";
  47.  }
  48.  
  49.  closedir($otwiera);
  50.  
  51. }
  52. $katalogrok = trim($_POST['katalogrok']);
  53. if($katalogrok) {
  54. mkdir("_ZGK/Przetargi/". $katalogrok, 0777);
  55. echo ("<script>alert('Dodano nowy rok prawidłowo');window.self.location.href='index.php';</script>");
  56. }
  57. ?>
  58. <form action="index.php" method="post">
  59. Utwurz nowy rok:<br />
  60. <input type="tinyint" name="katalogrok" /><br />
  61. <input type="submit" value="utwórz" />
  62. </form>

Witam!! potrzebuje pomocy aby zrobić takie cos gdy dodaje nazwe nowego folderu i wpisana nazwa juz istnieje niech wyskoczy komunikat taka nazwa juz istnieje.
acztery
z is_dir" title="Zobacz w manualu php" target="_manual powinno cos sie wymyslic

  1. <?php
  2.  
  3. /*
  4.  * Function to check recursively if dirname is exists in directory's tree
  5.  *
  6.  * @param string $dir_name
  7.  * @param string [$path]
  8.  * @return bool
  9.  * @author FanFataL
  10.  */
  11. function dir_exists($dir_name = false, $path = './') {
  12.  if(!$dir_name) return false;
  13.  
  14.  if(is_dir($path.$dir_name)) return true;
  15.  
  16.  $tree = glob($path.'*', GLOB_ONLYDIR);
  17.  if($tree && count($tree)>0) {
  18.  foreach($tree as $dir)
  19.  if(dir_exists($dir_name, $dir.'/'))
  20.  return true;
  21.  }
  22.  
  23.  return false;
  24. }
  25. ?>
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.