Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] file_exists, dla kilku plików ?
Xeon
post 2.11.2007, 15:27:03
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 2.11.2007
Skąd: Poznań

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


Jak przerobic te skrypty żeby sprawdzały więcej niż jeden plik i wyświetlały to w tabeli [opcionalnie] ?

Kod
   <?php  
   $filename = 'plik.rar';
    
   if (file_exists($filename)) {  
       echo "Plik $filename istnieje";  
   } else {  
       echo "Plik $filename nie istnieje";  
   }  
   ?>


Kod
     <?php
     $filename = 'plik.rar';
    
     if (file_exists($filename))
     {
         echo"Plik $filename istnieje\n";
         $file = md5_file($filename);
         print $file;
     } else {
         echo "Plik $filename nie istnieje";
     }
     ?>


--------------------
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
skowron-line
post 2.11.2007, 15:37:53
Post #2





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


  1. <?php
  2. $files = array('a.php','b.php');
  3. foreach($files as $key => $name){
  4.  if (file_exists($name))
  5.  {
  6.  echo"Plik $filename istnieje\n";
  7.  $file = md5_file($name);
  8.  print $name;
  9.  } else {
  10.  echo "Plik $filename nie istnieje";
  11.  }
  12. }
  13. ?>


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
Xeon
post 2.11.2007, 15:52:10
Post #3





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 2.11.2007
Skąd: Poznań

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


wszystko dobrze tylko niewyświetla wartości MD5


--------------------
Go to the top of the page
+Quote Post
nospor
post 2.11.2007, 15:55:41
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Cytat
wszystko dobrze tylko niewyświetla wartości MD5
Tak to jest jak sie bezmyslnie kopiuje i nie pomysli....

nie:
  1. <?php
  2. print $name;
  3. ?>

a:
  1. <?php
  2. print $file;
  3. ?>


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
Xeon
post 2.11.2007, 16:27:41
Post #5





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 2.11.2007
Skąd: Poznań

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


dobra dodalem też SHA1 zeby bylo śmieszniej smile.gif

  1. <?php
  2. $files = array('plik1','plik2','plik3');
  3. foreach($files as $key => $name){
  4.  if (file_exists($name))
  5.  {
  6.  echo"$name <b><font color=green>on</font></b>\n";
  7.  $file1 = md5_file($name);
  8.  $file2 = sha1_file($name);
  9.  echo"<b>MD5</b>\n";
  10.  print $file1;
  11.  echo"\n";
  12.  echo"<b>SHA1</b>\n";
  13.  print $file2;
  14.  echo"<br>";
  15.  } else {
  16.  echo"$name <b><font color=red>off</font></b>";
  17.  echo"<br>";
  18.  }
  19. }
  20. ?>


Ten post edytował Xeon 2.11.2007, 16:31:08


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 25.07.2025 - 00:07