Hallo!
Irgendwie komme ich gerade nicht weiter. Ich habe die folgende Funktion, die schon mehrere Monate erfolgreich im Einsatz ist. Seit ein paar Tagen macht sie Mätzchen. Ich kriege ab und zu (nicht immer!) den Fehler "Konnte das Bild $i leider nicht erstellen."
Für Hilfe wäre ich sehr dankbar.
Gruß Moritz.
Irgendwie komme ich gerade nicht weiter. Ich habe die folgende Funktion, die schon mehrere Monate erfolgreich im Einsatz ist. Seit ein paar Tagen macht sie Mätzchen. Ich kriege ab und zu (nicht immer!) den Fehler "Konnte das Bild $i leider nicht erstellen."
Für Hilfe wäre ich sehr dankbar.
Gruß Moritz.
PHP-Code:
function editfoto2() {
# vars holen und checken
$ID = $_POST['ID'];
$Quality = 75;
$i = 0;
while ($i < 4) {
$i++;
$Location = "../images/$ID-$i.jpg";
$LocationThumbnail = "../images/thumbs/$ID-$i.jpg";
if ($_FILES["BILD$i"]['tmp_name']) {
# bild verkleinern
list($Width, $Height) = GetImageSize($_FILES["BILD$i"]['tmp_name']);
# Bilder sollen 400px breit oder hoch sein
# neue Maße errechnen
if ($Width > 400) {
$NewWidth = 400;
$NewHeight = round(400*$Height/$Width);
} else {
$NewWidth = $Width;
$NewHeight = $Height;
}
if ($Width > 144) {
$ThumbnailWidth = 144;
$ThumbnailHeight = round(144*$Height/$Width);
} else {
$ThumbnailWidth = $Width;
$ThumbnailHeight = $Height;
}
$OrgImage = imagecreatefromjpeg($_FILES["BILD$i"]['tmp_name']);
# bild erstellen
$NewImage = imagecreatetruecolor($NewWidth,$NewHeight);
imagecopyresized($NewImage, $OrgImage,
0, 0, 0, 0,
$NewWidth, $NewHeight, $Width, $Height);
if (!imagejpeg($NewImage, $Location, $Quality)) {
$Return = array('-', "Konnte das Bild $i leider nicht erstellen.");
return $Return;
}
#thumbnail erstellen
$NewImage = imagecreatetruecolor($ThumbnailWidth,$ThumbnailHeight);
imagecopyresized($NewImage, $OrgImage,
0, 0, 0, 0,
$ThumbnailWidth, $ThumbnailHeight, $Width, $Height);
if (!imagejpeg($NewImage, $LocationThumbnail, $Quality)) {
$Return = array('-', "Konnte das Thumbnail vom Bild $i leider nicht erstellen.");
return $Return;
}
# in db updaten
$this->Handler[DB]->update(
'mallorca_estates',
array(
"bild$i" => "$ID-$i.jpg",
),
"estateid = '$ID'"
);
}
}
# daten holen
list($bild1, $bild2, $bild3, $bild4) = $this->Handler[DB]->Select_Single(
'bild5, bild6, bild7, bild8',
'mallorca_estates',
"estateid = '$ID'"
);
$vars = array(
bild1 => $bild1,
bild2 => $bild2,
bild3 => $bild3,
bild4 => $bild4,
ID => $ID,
);
$Return = array('+', $vars);
return $Return;
}

Kommentar