Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Dodawanie zdjec do galeri
-Gość-
post 3.03.2012, 14:40:44
Post #1





Goście







Witam, a wiec mam skrypt który laduje wszystkie obrazki z folderu "/gallery", generuje kod dla kazdego i je wyswietla.
Wszystko ladnie pieknie gra tylko, ze w tym folderze mam jeszcze inny folder (galeria_mini), w którym trzymam pomniejszone zdjecia i niestety mój skrypt laduje ten folder do galerii jako pusty obiekt.

Jak to naprawić, tzn. zeby podczas ładowania omijało ten folder?

  1. <?php
  2. $dir = 'gallery/';
  3.  
  4. if ($handle = opendir($dir))
  5. {
  6. while ($file = readdir($handle)) {
  7. if ($file != "." && $file != "..")
  8. {
  9. $option[] = $file ;
  10. }
  11. }
  12. closedir($handle);
  13. foreach($option as $key=>$val)
  14. {
  15. $gallery ='<div class="imageElement">
  16.  
  17. <h3></h3>
  18. <p></p>
  19.  
  20. <a href="#" title="open image" class="open"></a>
  21.  
  22. <img src="gallery/'.$val.'" class="full" />
  23.  
  24. <img src="gallery/gallery_mini/'.$val.'" class="thumbnail" />
  25.  
  26. </div>';
  27. echo $gallery;
  28. }
  29. }
  30. ?>


Próbowałem:
if ($file != "." && $file != ".." && $file != "galeria_mini")
lecz nic.

Pozdrawiam i proszę o pomoc
Go to the top of the page
+Quote Post
jaslanin
post 4.03.2012, 18:55:30
Post #2





Grupa: Zarejestrowani
Postów: 511
Pomógł: 143
Dołączył: 13.03.2010
Skąd: Jasło

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


  1.  
  2. $ext = pathinfo($file_path, PATHINFO_EXTENSION);
  3. if (in_array($ext, array('jpg', 'jpeg', 'png', 'gif', 'JPG', 'JPEG', 'PNG', 'GIF')) == FALSE) {
  4. continue;
  5. }


--------------------
Good luck and happy PHP'ing
Go to the top of the page
+Quote Post
mat-bi
post 4.03.2012, 18:58:20
Post #3





Grupa: Zarejestrowani
Postów: 690
Pomógł: 92
Dołączył: 6.02.2011

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


Hmm, a is_dir ?
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: 18.06.2025 - 04:07