Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Fatal error: Call to undefined function: scandir() in on line 33, problem podczas wyswietlania zdjęć
nikos
post 17.10.2009, 11:38:24
Post #1





Grupa: Zarejestrowani
Postów: 88
Pomógł: 0
Dołączył: 30.03.2009

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


Chciałem wyświetlić zdjęcia z folderu za pomocą skryptu.
  1. ...
  2. $dir=slowo($r['nazwa hotelu/imprezy']);
  3. $imagesExtensions = array('jpg', 'jpeg', 'gif', 'png','JPG');
  4. $files = scandir($dir);
  5. foreach($files AS $file) {
  6. $fileinfo = pathinfo($file);
  7. if(is_file($dir.'/'.$file) AND in_array($fileinfo['extension'], $imagesExtensions)) {
  8. echo '<img src="http://travelos.pl/skrypty/images/'.$dir.'/'.$file.'" alt="" />';
  9. }
  10. }
  11. ...

Fatal error: Call to undefined function: scandir() in on line 33

Gdzie może być błąd? Czy może w ścieżce dir?

Ten post edytował nikos 17.10.2009, 12:34:30
Go to the top of the page
+Quote Post
foxik000000
post 17.10.2009, 11:51:48
Post #2





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 8.02.2009

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


Możliwe, iż na serwerze na którym próbujesz uruchomić skrypt wyłączona jest funkcja scandir().
Go to the top of the page
+Quote Post
Kszyhuu
post 17.10.2009, 11:52:11
Post #3





Grupa: Zarejestrowani
Postów: 157
Pomógł: 32
Dołączył: 24.08.2009

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


  1. ...
  2. dir=slowo($r['nazwa hotelu/imprezy']);
  3.  
  4. $files = scandir($dir);
  5. ...

Nie zrobiłeś zmiennej $dir


Go to the top of the page
+Quote Post
nikos
post 17.10.2009, 12:36:16
Post #4





Grupa: Zarejestrowani
Postów: 88
Pomógł: 0
Dołączył: 30.03.2009

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


Zmienna była tylko mi się nie wkleiła jeśli serwer ma wyłączoną tą funkcję to czy istnieje jakiś prosty skrypt który wczytuje fotki na stronę? bez tej funkcji? nie znam ilości zdjęć oraz nazw. Znam tylko nazwę folderu gdzie są
Go to the top of the page
+Quote Post
viking
post 17.10.2009, 12:45:53
Post #5





Grupa: Zarejestrowani
Postów: 6 378
Pomógł: 1116
Dołączył: 30.08.2006

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


SPL: DirectoryIterator::getFilename
Nawet masz przykład w dokumentacji akurat do swojego przypadku.


--------------------
Go to the top of the page
+Quote Post
nikos
post 17.10.2009, 20:27:40
Post #6





Grupa: Zarejestrowani
Postów: 88
Pomógł: 0
Dołączył: 30.03.2009

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


Dzięki niestety na serwerze na ktorym jest ta strona nie dziala ;/ na lokalnym swojim hula a tu
Fatal error: Cannot instantiate non-existent class: directoryiterator

Działa mi taki skrypt
  1. <?PHP
  2. if(!isset($foto)) {
  3. //wyświetlenie listy
  4. echo "<b>$title</b><br><BR>";
  5. $OpenDir=opendir(images/$slowo);
  6. $i=0;
  7. while (($katalog = readdir($OpenDir))!=false) {
  8. if(($katalog!=".")&&($katalog!="..")&&(!is_dir($katalog)) &&(substr($katalog,-4)==".jpg")||(substr($katalog,-4)==".JPG")) {
  9. $i++;
  10. if($show_style=="1"){
  11. echo("<a href='?foto=$katalog&$param'>$i</a>&nbsp; ");
  12. }elseif($show_style=="0"){
  13. if(file_exists("small/".$katalog)){
  14. echo("<a href='?foto=$katalog&$param'><img src='small/$katalog'></a>&nbsp; ");
  15. }elseif(file_exists("mini/".$katalog)){
  16. echo("<a href='?foto=$katalog&$param'><img src='mini/$katalog'></a>&nbsp; ");
  17. }else{
  18. echo("<a href='?foto=$katalog&$param'><img src='$katalog'></a>&nbsp; ");
  19. }
  20. }
  21. }
  22. }
  23. echo("<BR><p class=small align=left>tFotoView by tas - <a href='http://tas.klamstwo.org' target='_blank'>tas.klamstwo.org</a></p>");
  24. }
  25. elseif(isset($foto)) {
  26. //wyświetlenie zdjęcia
  27. echo "<b>$title</b>&nbsp;&nbsp;&nbsp;&nbsp;<small><a href='?$param'>Powrót do spisu</a></small><BR><BR><BR>";
  28. $OpenDir=opendir("./");
  29. $i=0;
  30. while (($katalog = readdir($OpenDir))!=false) {
  31. if(($katalog!=".")&&($katalog!="..")&&(!is_dir($katalog)) &&(substr($katalog,-4)==".jpg")||(substr($katalog,-4)==".JPG")) {
  32. $i++;
  33. echo("<a href='?foto=$katalog&$param'>$i</a>&nbsp; ");
  34. if(($foto)!=$katalog) {
  35. if(!isset($next)) $next=$katalog;
  36. if($p==0) $prev=$katalog;
  37. if($oki==0) {
  38. $prev=$katalog;
  39. $p=1;
  40. }
  41. if($oki==1) {
  42. $next=$katalog;
  43. $oki=2;
  44. }
  45. }
  46. else {
  47. $oki=1;
  48. }
  49. }
  50. }
  51. echo "<br><BR><BR>";
  52. if(file_exists($foto)){
  53. echo("<table border=0><tr><td align=center valign=middle> <a href='?foto=$prev'><<</a> </td><td><img src='$foto'></td><td align=center valign=middle> <a href='?foto=$next'>>></a> </td></tr></table><BR><p class=small align=left>tFotoView by tas - <a href='http://tas.klamstwo.org' target='_blank'>tas.klamstwo.org</a></p>");
  54. }
  55. }
  56. ?>
  57. </td></tr></table>
  58. </BODY>
  59. </HTML>
  60. <?PHP
  61. ?>


tylko nie wiem jak zmodyfikowac folder nie wyswietla mi zawartosci folderu ;/
  1. $OpenDir=opendir(images/$slowo);
Go to the top of the page
+Quote Post
dr_bonzo
post 17.10.2009, 20:39:21
Post #7





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

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


No to chyba masz php 4 http://pl.php.net/manual/en/function.scandir.php


--------------------
Nie lubię jednorożców.
Go to the top of the page
+Quote Post
kehator
post 1.06.2010, 12:47:43
Post #8





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 23.05.2009

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


Witam
mam też problem z tą funkcją. Serwer niby obsługuje PHP5 (ovh) ,ale skrypt strony jest z PHP4. i teraz probując dodać pasek cometchat, mam problem ze zmianą skina paska. Najprawdopodobniej muszę zmienić tą funkcję, ponieważ korzysta ona z "scandir" a to powoduje error:
Cytat
PHP Fatal error: Call to undefined function: scandir() in /......../themechanger/index.php


Kiedy tylko zmieniam nazeę z scandor na "opendir", to powoduje kolejny problem:
Cytat
PHP Warning: Invalid argument supplied for foreach() in /......../themechanger/index.php


cała funkcja wygląda tak:
Cytat
$dir = dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR."themes";
$files = scandir($dir);
foreach ($files as $listedtheme){
if (is_dir($dir."/".$listedtheme) && $listedtheme != '' && !preg_match('/^\.(.*)/',$listedtheme)) {
$themename = ucfirst($listedtheme);
if ($theme != $listedtheme) {
$themeslist .= <<<EOD
<a href="java script:void(0);" onclick="java script:changeTheme('{$listedtheme}')">{$themename}</a><br/>
EOD;
}
}
}


nie daje rady z poprawą sad.gif
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: 13.07.2025 - 14:57