Jeg tror du kan bruge denne kode:
Du smider index.php i selve mappen, så laver den thumbs af alle filer, som ikke allerede har fået lavet det.
Hvis scriptet timer ud, så reload indtil alle filer er renamed!
Har ikke lige gidet at sætte set_time_limit() i scriptet! :o)
<?php
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Strict //EN\" \"
http://www.w3.org/TR/html4/strict.dtd\">\n";echo "<html>\n";
echo "<head>\n";
echo "<title>Title</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\n";
echo "</head>\n";
echo "<body>\n";
echo "<div id=\"content\">\n";
echo "<h1>Title</h1>\n";
function resize( $filename, $newfilename, $maxw, $maxh )
{
$result = false;
$srcim = imagecreatefromjpeg( $filename );
$ow = imagesx( $srcim );
$oh = imagesy( $srcim );
$wscale = $maxw / $ow;
$hscale = $maxh / $oh;
$scale = ( $hscale < $wscale ? $hscale : $wscale );
$nw = round( $ow * $scale, 0 );
$nh = round( $oh * $scale, 0 );
$dstim = imagecreatetruecolor( $nw, $nh );
imagecopyresampled( $dstim, $srcim, 0, 0, 0, 0, $nw, $nh, $ow, $oh );
$result = imagejpeg( $dstim, $newfilename, 85 );
imagedestroy( $dstim );
imagedestroy( $srcim );
return $result;
}
$dir = getcwd();
$allowExt = array("jpg");
// Open a known directory, and proceed to read its contents
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
$fileArray = array();
while(($file = readdir($dh)) !== false)
{
$arr = explode (".", $file);
$extension = end($arr);
if(in_array($extension,$allowExt))
{
if(file_exists("thumb_" . $file) || preg_match('/^thumb_/', $file))
{
;
}
else
{
resize($file, getcwd() . "/thumb_" . $file, 300, 300);
}
if(!preg_match('/^thumb_/', $file))
{
$thumb = "thumb_" . $file;
$fileArray[$thumb] = $file;
}
}
}
closedir($dh);
}
}
if(count($fileArray)>0)
{
echo "<table id=\"centerTable\">\n";
foreach($fileArray as $thumb => $file)
{
echo "<tr><td><a target=\"_blank\" href=\"" . $file . "\"><img src=\"".$thumb."\"></a></td></tr>\n";
}
echo "</table>\n";
}
else
{
echo "Vi har ikke uploadet nogle billeder endnu, de kommer...";
}
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
?>