Shiivva
Erfahrenes Mitglied
Irgendwie wird folgendes Script nicht so durchgeführt, wie es soll?!
Das "Problem" ist, dass die Bilder nicht angezeigt werden, sondern
die Dateinamen einfach nur ausgeschrieben werden:
hier der Beispiellink: http://www.shiivva.de/random
Und hier das Script:
<?php
// print a random image. Don't forget ending slash!
// setting $type to 'all' will return all images.
print getRandomImage('../images/');
function getRandomImage($dir,$type='random')
{
global $errors;
if (is_dir($dir)) {
$fd = opendir($dir);
$images = array();
while (($part = @readdir($fd)) == true) {
clearstatcache();
if ( eregi("(gif|jpg|png|jpeg)$",$part) ) {
$images[] = $part;
}
}
// adding this in case you want to return the image array
if ($type == 'all') { return $images; }
// Be sure to call srand() once per script
srand ((double) microtime() * 1000000);
$key = rand (0,sizeof($images)-1);
return $dir . $images[$key];
} else {
$errors[] = $dir.' is not a directory';
return false;
}
}
?>
Was ist das Problem? Oder funktioniert das Script einfach nur "mal wieder" bei Puretec nicht?
Das "Problem" ist, dass die Bilder nicht angezeigt werden, sondern
die Dateinamen einfach nur ausgeschrieben werden:
hier der Beispiellink: http://www.shiivva.de/random
Und hier das Script:
<?php
// print a random image. Don't forget ending slash!
// setting $type to 'all' will return all images.
print getRandomImage('../images/');
function getRandomImage($dir,$type='random')
{
global $errors;
if (is_dir($dir)) {
$fd = opendir($dir);
$images = array();
while (($part = @readdir($fd)) == true) {
clearstatcache();
if ( eregi("(gif|jpg|png|jpeg)$",$part) ) {
$images[] = $part;
}
}
// adding this in case you want to return the image array
if ($type == 'all') { return $images; }
// Be sure to call srand() once per script
srand ((double) microtime() * 1000000);
$key = rand (0,sizeof($images)-1);
return $dir . $images[$key];
} else {
$errors[] = $dir.' is not a directory';
return false;
}
}
?>
Was ist das Problem? Oder funktioniert das Script einfach nur "mal wieder" bei Puretec nicht?