corsanostra
Mitglied
Habe mal wieder ein kleines Problem:
Ich habe ein Thumbnail-Script, welches als Stan-Alone-Script auch super funktioniert. Nun habe ich es angepasst so das es in einer Tabelle und mit verschiedenen Funktionen (Ordner erstellen/löschen, upload) arbeitet. Nun macht er aber die Thumbnail-erstellung nicht mehr. Alles andere wie z.B. das Popup mit dem hineingeladenen Bild funktioniert und laut Quelltext ist auch der Link zum Thumb okay. Dennoch macht er es nicht. Könntet ihr mal schauen was evtl. der Fehler sein könnte? Hier der Code:
P.S.: Auf meinem Rechner funktioniert es.. nur nicht im WEB!
Ich habe ein Thumbnail-Script, welches als Stan-Alone-Script auch super funktioniert. Nun habe ich es angepasst so das es in einer Tabelle und mit verschiedenen Funktionen (Ordner erstellen/löschen, upload) arbeitet. Nun macht er aber die Thumbnail-erstellung nicht mehr. Alles andere wie z.B. das Popup mit dem hineingeladenen Bild funktioniert und laut Quelltext ist auch der Link zum Thumb okay. Dennoch macht er es nicht. Könntet ihr mal schauen was evtl. der Fehler sein könnte? Hier der Code:
PHP:
<?php
$directory = $HTTP_GET_VARS["dir"];
function createimage($width, $height){
$imgh = imagecreatetruecolor($width, $height);
$bgc = imagecolorallocate($imgh, 230, 230, 230);
return $imgh;
}
if($path){ // Thumbnail
$height = 50; // Maximalhöhe
$width = 120; // Maximalbreite
$img_size = getimagesize($path);
$img_size[4] = $img_size[1]/$height;
$faktor = 100/$img_size[4];
$img_size[1] = $img_size[1]/100;
$img_size[0] = $img_size[0]/100;
$img_size[1] = $img_size[1]*$faktor;
$img_size[0] = $img_size[0]*$faktor;
if($img_size[0] >= 120){
$img_size[4] = $img_size[0]/$width;
$faktor2 = 100/$img_size[4];
if($faktor2 << $faktor){
$img_size[1] = $img_size[1]/100;
$img_size[0] = $img_size[0]/100;
$img_size[1] = $img_size[1]*$faktor2;
$img_size[0] = $img_size[0]*$faktor2;
}
}
$imgh = createimage($img_size[0], $img_size[1]);
$imgh2 = imagecreatefromjpeg($path);
$imgsz = getimagesize($path);
$black = imagecolorallocate($imgh2, 0, 0, 0);
imagecopyresized($imgh, $imgh2, 0, 0, 0, 0, $img_size[0], $img_size[1], $imgsz[0], $imgsz[1]);
header("Content-Type: image/jpeg");
imagejpeg($imgh, '', 100);
imagedestroy($imgh);
} else { // Dateianzeige
$mydir = dir("./$directory/");
$zahl = count($mydir);
while($file=$mydir->read()) {
if(getimagesize("./$directory/$file")){
echo '<script language="javascript" type="text/javascript">
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
"height="+h+",width="+w+",top="+TopPosition+",left="+LeftPosition+",scrollbars="+scroll+",resizable"
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}
</script> ';
$b = 20; // pixel für den bilderrand (breite) im popup
$d = 25; // pixel für den bilderrand (höhe) im popup
$file_properties = getimagesize("./$directory/$file");
$a = $file_properties[0]; // bildbreite werden ausgelesen
$c = $file_properties[1]; // bildhöhe wird ausgelesen
$parts = explode("/", $img);
$fn = $parts[count($parts) - 1];
$width = $a + $b; // bildbreite + rand
$height = $c + $d; //bildhöhe + rand
echo '<a href="javascript:NewWindow(\'show.php?pic=' . $directory . '/'. $file .'&breite='. $width .'&hoehe='. $height .'\',\'win\','. $width .','. $height .',\'no\')"><img src="thumb.php?path=' . $directory . '/' . $file . '" border=0></a>';
}
}
}
echo "<br><br><br><br><br><br>";
?>
<html>
<head>
<title><? echo $directory ?></title>
</head>
<body bgcolor="#666666">
<center>
<form enctype="multipart/form-data" action="index.php?action=upload&dir=<? echo $directory ?>" method="post">
<input name="file" type="file">
<input type="submit" value="hochladen" name="submit">
<br>
</form>
</center>
</body>
</html>
P.S.: Auf meinem Rechner funktioniert es.. nur nicht im WEB!