Hallo,
wollte gerade mein Script auf eine While Schleife umstellen damit es nicht rund 1300 Zeilen lang wird ;-)
Nun hab ich aber irgendwo einen Fehler und werde einfach nicht mehr schlau.
Hier mal das Script, Fehlermeldung folgt unten im Beitrag:
Fehlermeldung: Warning: chmod(): No such file or directory in /var/www/web222/html/develop/admin/screens.php on line 187
Warning: getimagesize(/var/www/web222/html/develop/media/images/screens/10/upload/POP2_screen4.jpg): failed to open stream: No such file or directory in /var/www/web222/html/develop/admin/screens.php on line 192
Warning: unlink(/var/www/web222/html/develop/media/images/screens/10/upload/POP2_screen4.jpg): No such file or directory in /var/www/web222/html/develop/admin/screens.php on line 197
Warning: Cannot modify header information - headers already sent by (output started at /var/www/web222/html/develop/admin/screens.php:12) in /var/www/web222/html/develop/admin/screens.php on line 198
Wie gesagt - bis jetzt funktionierte das Script problemlos...
Danke für die Hilfe,
Christoph
wollte gerade mein Script auf eine While Schleife umstellen damit es nicht rund 1300 Zeilen lang wird ;-)
Nun hab ich aber irgendwo einen Fehler und werde einfach nicht mehr schlau.
Hier mal das Script, Fehlermeldung folgt unten im Beitrag:
PHP-Code:
<?php
if ($_POST["Submit2"]) {
$bildcount=0;
if ($pic1!='') $bildcount++;
if ($pic2!='') $bildcount++;
if ($pic3!='') $bildcount++;
if ($pic4!='') $bildcount++;
if ($pic5!='') $bildcount++;
if ($pic6!='') $bildcount++;
// Überprüfen ob Verzeichnise gelöscht oder erstellt werden müssen
$dirtofile='/var/www/web222/html/develop/media/images/screens/'.$gameindex;
if (!file_exists($dirtofile)) {
mkdir('/var/www/web222/html/develop/media/images/screens/'.$gameindex, 0755);
}
$dirtofile='/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/original';
if (!file_exists($dirtofile)) {
mkdir('/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/original', 0755);
}
$dirtofile='/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/edited';
if (!file_exists($dirtofile)) {
mkdir('/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/edited', 0755);
}
$dirtofile='/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/thumbs';
if (!file_exists($dirtofile)) {
mkdir('/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/thumbs', 0755);
}
$dirtofile='/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/thumbs_original';
if (!file_exists($dirtofile)) {
mkdir('/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/thumbs_original', 0755);
}
$dirtofile='/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/mini';
if (!file_exists($dirtofile)) {
mkdir('/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/mini', 0755);
}
$dirtofile='/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/upload';
if (!file_exists($dirtofile)) {
mkdir('/var/www/web222/html/develop/media/images/screens/'.$gameindex.'/upload', 0755);
}
$anzahl=1;
while ($anzahl <= $bildcount)
{
$endung="jpg";
// Datei auf Grösse kontrollieren
$maxsize = 1024; // KB
$maxsize = $maxsize * 1024; // Umwandlung in Byte
if ($_FILES['pic1']['size'] > $maxsize)
{
header ("location: upload_error.php"); exit;
}
// Datei verschieben
$diru = "/var/www/web222/html/develop/media/images/screens/$gameindex/upload/";
$dir = "/var/www/web222/html/develop/media/images/screens/$gameindex/edited/";
$dirm = "/var/www/web222/html/develop/media/images/screens/$gameindex/thumbs_original/";
$dirmt = "/var/www/web222/html/develop/media/images/screens/$gameindex/thumbs/";
$dirm2 = "/var/www/web222/html/develop/media/images/screens/$gameindex/original/";
$dirm3 = "/var/www/web222/html/develop/media/images/screens/$gameindex/mini/";
if ($_FILES['pic1']['size'] > "0")
{
$filename=$_FILES['pic1']['name'];
$oldname=$filename;
move_uploaded_file ($pic1, "$diru$filename");
chmod ("$diru$filename", 0644);
}
// Datei auf Typ kontrollieren und wenn nötig wieder löschen
$fileinfos = getimagesize("$diru$filename");
$type = $fileinfos[2]; // 2 = JPG
if ($type != 2)
{
unlink("$diru$filename"); // Löschen
header ("location: upload_error.php"); exit;
}
// Thumbnail erstellen
//////////////////////
// Anmerkungen:
//
// $dir = Pfad für das Verzeichnis, in dem sich das upgeloadete Bild befindet
// $filename = dateiname.jpg
// Größe des Bildes auslesen
$size = getimagesize("$diru$filename");
$width = $size[0];
$height = $size[1];
// Breite des Thumbnails festlegen (Höhe wird automatisch angepasst)
$width_tn = 640;
$height_tn = intval($height * $width_tn / $width);
$width_tn2 = 150;
$height_tn2 = 113;
$width_tn3 = 80;
$height_tn3 = 60;
// Bei GD < 2.0.1: ImageCreateTrueColor -> ImageCreate, ImageCopyResampled -> ImageCopyResized
$picture = ImageCreateFromJPEG("$diru$filename");
$picture_tn = ImageCreateTrueColor($width_tn,$height_tn);
ImageCopyResampled($picture_tn,$picture,0,0,0,0,$width_tn,$height_tn,$width,$height);
$picture2 = ImageCreateFromJPEG("$diru$filename");
$picture_tn2 = ImageCreateTrueColor($width_tn2,$height_tn2);
ImageCopyResampled($picture_tn2,$picture2,0,0,0,0,$width_tn2,$height_tn2,$width,$height);
$picture3 = ImageCreateFromJPEG("$diru$filename");
$picture_tn3 = ImageCreateTrueColor($width_tn3,$height_tn3);
ImageCopyResampled($picture_tn3,$picture3,0,0,0,0,$width_tn3,$height_tn3,$width,$height);
// Thumbnail in $dir mit angepasstem $filename speichern, JPG Qualität: 80
ImageJPEG($picture_tn2,"$dirm$bildcount.$endung",80);
ImageJPEG($picture_tn,"$dirm2$bildcount.$endung",90);
ImageJPEG($picture_tn3,"$dirm3$bildcount.$endung",70);
// Bild mit aufgedrucktem Logo erstellen (liegt danach im Ordner edited)
$background = imagecreatefromjpeg("$dirm$bildcount.$endung");
$insert = imagecreatefromgif("../media/images/vorlagen/show.gif");
// Either a color at a specific point on the image
// imagecolortransparent($insert,imagecolorat($insert,0,0));
// or a specific color (the color I used is magenta, #ff00ff)
imagecolortransparent($insert,imagecolorexact($insert,255,0,255));
$insert_x = imagesx($insert);
$insert_y = imagesy($insert);
// As said above, you can't use imagecopy (bug?)
imagecopymerge($background,$insert,0,0,0,0,$insert_x,$insert_y,100);
// imagejpeg or imagepng doesn't matter here
imagejpeg($background,"$dirmt$bildcount.$endung",85);
// Bild mit aufgedrucktem Logo erstellen (liegt danach im Ordner edited)
$background = imagecreatefromjpeg("$dirm2$bildcount.$endung");
$insert = imagecreatefromgif("../media/images/vorlagen/game2_logo_screens.gif");
// Either a color at a specific point on the image
// imagecolortransparent($insert,imagecolorat($insert,0,0));
// or a specific color (the color I used is magenta, #ff00ff)
imagecolortransparent($insert,imagecolorexact($insert,255,0,255));
$insert_x = imagesx($insert);
$insert_y = imagesy($insert);
// As said above, you can't use imagecopy (bug?)
imagecopymerge($background,$insert,0,0,0,0,$insert_x,$insert_y,25);
// imagejpeg or imagepng doesn't matter here
imagejpeg($background,"$dir$bildcount.$endung",85);
// Temporären Speicher auf Server wieder frei geben
$filetyp=jpg;
$oldname2 = explode (".", $oldname);
$tn = "_tn.";
unlink("$diru$oldname");
ImageDestroy($picture);
ImageDestroy($picture_tn);
ImageDestroy($picture_tn2);
ImageDestroy($picture_tn3);
}
{
$anzahl++;
} rmdir("$diru");
}
?>
Fehlermeldung: Warning: chmod(): No such file or directory in /var/www/web222/html/develop/admin/screens.php on line 187
Warning: getimagesize(/var/www/web222/html/develop/media/images/screens/10/upload/POP2_screen4.jpg): failed to open stream: No such file or directory in /var/www/web222/html/develop/admin/screens.php on line 192
Warning: unlink(/var/www/web222/html/develop/media/images/screens/10/upload/POP2_screen4.jpg): No such file or directory in /var/www/web222/html/develop/admin/screens.php on line 197
Warning: Cannot modify header information - headers already sent by (output started at /var/www/web222/html/develop/admin/screens.php:12) in /var/www/web222/html/develop/admin/screens.php on line 198
Wie gesagt - bis jetzt funktionierte das Script problemlos...
Danke für die Hilfe,
Christoph
Kommentar