fixed the above by just adding images dir before the img src output.
Quote:
Originally Posted by Oracle Porn
you mind posting the entire edited code? 
thanks
|
ofcourse, here it is.
script is at:
mysite.com/script/script.php
Images in:
mysite.com/script/images/
Code:
Code:
<?php
define('BASE_DIR', '/home/user/domains/mysite.com/public_html/script/images/'); // Where are your images?
define('IMAGE_LIMIT', 5); // how many images to show?
$files = glob(BASE_DIR.'*');
$images = Array();
if(empty($files)) {
die("Hey, dude, there are no files. What happened?");
}
foreach($files as $v) {
if(is_dir($v)) {
foreach($files as $v) { // This should be a function which can loop through further sub directories if needed
//get exif image type, if it's an image append to array
$images[] = $v;
}
} else {
$images[] = $v;
}
}
shuffle($images); // Randomise the array
for($i=0;$i<IMAGE_LIMIT;$i++) {
$img = $images[$i];
if(empty($img)) {
break; // Might be best doing a foreach above whilst keeping $i as a loop counter and breaking the loop once you reach the limit
}
$img_src = end(explode("/", $img));
$imgid = basename($img, ".jpg");
echo "<a href='http://www.mysite.com/id=$imgid'><img src='images/{$img_src}'/></a>";
}
?>
Takes filename of pic (which is also the url ID) to link every pic to its own ID page.