Need some help with PHP sessions(I quess so). My php code should be outputting to browser all images in a specified folder, but for some reasons it outputs always the same image - the last one in folder. It reads files correctly, dislplays their names. It`s just the images that are always the same. I`m stuck here. Has it got to do with the session variables?
index.php
Code: Select all
<? session_start();
header("Content-type: image/jpeg");
$maindir="C:/web/docs/thumbs/";
$mydir = opendir($maindir);
$exclude = array(".", "..", "Thumbs.db") ;
while($fn = readdir($mydir)) {
if (!in_array($fn, $exclude)){
echo"$fn<br>";
$_SESSION["directory"]=$maindir;
$_SESSION["photo"]=$fn;
echo'<img src="next.php"/><br>';
}
}
closedir($mydir);
?>Code: Select all
<?php
session_start();
readfile($_SESSION["directory"].$_SESSION["photo"]);
?>