Einzelnen Beitrag anzeigen
Alt 17.02.2009, 13:31   #1 (permalink)
qLx
Tweaker
 
Benutzerbild von qLx
 

Registriert seit: 02.06.2008
Beiträge: 782

qLx sorgt für eine eindrucksvolle AtmosphäreqLx sorgt für eine eindrucksvolle AtmosphäreqLx sorgt für eine eindrucksvolle Atmosphäre

Standard [PHP] Dynamisches Bild / Random Picture

Hallo liebe Community

Wie kann man ein Bild auf einem Server ( z.B: http://xxxxxxx.de/images/random/Bild.jpg ) ein dynamisches Bild ablegen. Also ich möchte 1-5 Bilder in einen Ordner stecken und wenn ich ein Bild einfügen möchte soll immer ein anderes beim "reload" erscheinen. PHP möglich.

PHP-Code:
<?php
 $path 
"images2/random/";
 
$dir opendir($path);
 while(
$dat readdir($dir)){
  if(
$dat != "." && $dat != ".." && (substr($dat,-3) == "jpg" || substr($dat,-3) == "gif" || substr($dat,-3) == "png" || substr($dat,-3) == "bmp" || substr($dat,-3) == "JPG")){
   
$img_array[] = $dat;
   
$amount++;
  }
 }
 
$num rand(0,$amount-1);
 
$actual $img_array[$num];
  echo 
"   <img src=\"".$path.$actual."\" alt=\"Random Picture $i\" />\n"
?>
So schaut es aktuell bei mir aus. Aber dann kann ich ja nur auf das PHP Script verlinken!? Ich möchte also über "Grafik einfügen" http://xxxxxxx.de/images2/random/Bild.jpg eingeben können und das soll sich dann beim reload der Page neu laden.

MfG :Q123::L123::X123:
POW! :kungfu:
qLx ist offline   Mit Zitat antworten