Another php problem

Associate
Joined
18 Oct 2002
Posts
2,092
Location
Edinburgh
Im bassically trying to create thumbnails for my uploads page, if the thumb isnt there then it creates one. However, it seems to be doing just one at a time and im having to refresh to see another.

this is my code

Code:
foreach ($files as $filename) {
  $current_year = date('Y', filemtime($filename));
  $current_month = date('F', filemtime($filename));
  if($current_year != $previous_year) echo '<br><font size=+1><b>' . $current_year . '</b><br><br></font>';
  if($current_year == date('Y')){
  if($current_month != $previous_month) echo '<i><br><b>'.$current_month.'</b><br><br></i>';}
  $sizeoffile = (filesize($filename)/1024);
  $dateoffile = date("d/m/Y",filemtime($filename));
  $thumbfilename = 'thumb/'.$filename;
  if (file_exists($thumbfilename)){
     echo '<img height="50" width="50" src="http://www.mattinglis.com/thumb/'.$filename.'">   ';
  }else{
      chmod($filename, 0777);
      $thumb=new thumbnail('http://www.mattinglis.com/'.$filename);
      $thumb->size_auto(90);
      $thumb->save($thumbfilename);
      echo '<img height="50" width="50" src="http://www.mattinglis.com/thumb/'.$filename.'">   ';
  }
  echo '<a href="http://www.mattinglis.com/'.$filename.'">'.$filename.'</a>   ---                <b>Filesize</b> :  '.number_format($sizeoffile, 2, '.', '').' KBytes  -----         <b>Modified</b> : '.$dateoffile.'<br>';
  $previous_year = $current_year;
  $previous_month = $current_month;
}

$thumb comes from a resize script.

i cant understand how it works but then doesnt in the next item in the loop, yet does when you refresh.
 
A obvious one, but if you're getting the list of files dynamically, but have you tried doing a printr of $files?
 
haha read the whole sentence.

The reason is i use multiple methods for uploading files, usually either ftp or the form, so i want a script that will do them all in one.

of couse the problem will go away as soon as all the existing files have thumbnails, but if i were to upload another bunch then it would stall again.
 
Back
Top Bottom