Page 2 of 2

Posted: Thu Aug 03, 2006 10:41 am
by Luke
Kestas wrote:Thanks a lot!
Now it's all clear to me. All that I needed was "everything in PHP is compiled BEFORE the user sees ANYTHING on their screen"(by Jenk).
OF course... it's server-side, silly! :D

Posted: Thu Aug 03, 2006 11:37 pm
by Kestas
I know it`s server-side, but thought output is being sent during compilation. As I understood now, php sends it only after EVERYTHING is compiled.

Posted: Fri Aug 04, 2006 1:38 am
by Kestas
Thanks everyone, it works now. The solution was:

index.php

Code: Select all

<?php 
session_start(); 
header("Content-type: image/jpeg"); 
$maindir="C:/web/docs/sventes/saskrydis/thumbs/"; 
$mydir = opendir($maindir);
$_SESSION["directory"]=$maindir;  
$exclude = array(".", "..", "Thumbs.db") ; 
$list=array();
$i=0;
while($fn = readdir($mydir)) { 
  if (!in_array($fn, $exclude)) { 
    $list[$i]=$fn;  
    echo "$fn<br />"; 
    $_SESSION["list"]=$list;
    echo'<img src="next.php?id='.$i.'"/><br>'; 
    $i++;
  } 
}
closedir($mydir);
?>
next.php:

Code: Select all

<?php 
session_start(); 
readfile($_SESSION["directory"].$_SESSION["list"][$id]);  
?>