Jump to content

image thingy


yoshida
 Share

Recommended Posts

Hey it's me again. I stripped an image rotator like this:

<?php$folder = 'c:\WINDOWS\Web\Wallpaper./';$extList['jpg'] = 'image/jpeg';$handle = opendir($folder);while ($file = readdir($handle))  {	$file_info = pathinfo($file);	$fileList[] = $file;}$imageNumber = time() % count($fileList);header ('Content-type: '.$extList[ $imageInfo['extension'] ]);readfile($folder.$fileList[$imageNumber]);closedir($handle);?>

It displays a random image. I don't want that. I suspect it's because of $imageNumber's definition.How can I get this script to display all images in the folder? The folder name will be replaced by a variable which is propagated through a link. I'll make sure the folder exists and contains images.Thanks all.

Link to comment
Share on other sites

<?php$folder = 'c:\WINDOWS\Web\Wallpaper./';$extList['jpg'] = 'image/jpeg';$handle = opendir($folder);while ($file = readdir($handle))  {	$file_info = pathinfo($file);	$fileList[] = $file;}$imageNumber = time() % count($fileList);header ('Content-type: '.$extList[ $imageInfo['extension'] ]);readfile($folder.$fileList[$imageNumber]);closedir($handle);?>

to

<?php$folder = 'c:\WINDOWS\Web\Wallpaper./';$extList['jpg'] = 'image/jpeg';$handle = opendir($folder);while ($file = readdir($handle))  {	$file_info = pathinfo($file);	$fileList[] = $file;}for($i = "0", $i <= count($fileList), $i++){//echo out image, no clue how to do this lol.}closedir($handle);?>

Try that out :)

Link to comment
Share on other sites

Tried something very similar, but all I got was a blank screen when I enclosed the three rules (imagenumber, header and readfile)The part where you don't have a clue is the relevant part... lol :)

Link to comment
Share on other sites

Cracked it! (Almost...)

<?php$path=imgs;//Open images directory$dir = opendir("$path");//List files in images directorywhile (($file = readdir($dir)) !== false)  {  echo "<img src=$path\\$file>";  }  closedir($dir);?>

All I need to get rid off is 'false' images (<img src=imgs\.><img src=imgs\..>).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...