Sie können die Größe der temporären Datei ändern und dann die Datei speichern, nachdem sie abgeschlossen ist.
Hier ist, wie ich es normalerweise handhabe. BITTE BEACHTEN SIE, DASS SIE VIEL MEHR MIT SICHERHEIT DIESES UP! Stellen Sie sicher, dass Sie den Upload erlaubt Typ prüfen, wird Größe ect ..
ich diese Funktion verwenden, um die Größe ..
function img_resize($target, $newcopy, $w, $h, $ext) {
list($w_orig, $h_orig) = getimagesize($target);
$scale_ratio = $w_orig/$h_orig;
if (($w/$h) > $scale_ratio) {
$w = $h * $scale_ratio;
} else {
$h = $w/$scale_ratio;
}
$img = "";
$ext = strtolower($ext);
if ($ext == "gif"){
$img = imagecreatefromgif($target);
} else if($ext =="png"){
$img = imagecreatefrompng($target);
} else {
$img = imagecreatefromjpeg($target);
}
$tci = imagecreatetruecolor($w, $h);
// imagecopyresampled(dst_img, src_img, dst_x, dst_y, src_x, src_y, dst_w,
dst_h, src_w, src_h)
imagecopyresampled($tci, $img, 0, 0, 0, 0, $w, $h, $w_orig, $h_orig);
imagejpeg($tci, $newcopy, 80);
}
Dann rufe ich die Funktion mit der temporären Datei ..
$fileName = $_FILES["image"]["name"]; // The file name
$target_file = $_FILES["image"]["tmp_name"];
$kaboom = explode(".", $fileName); // Split file name into an array using the dot
$fileExt = end($kaboom); // Now target the last array element to get the file extension
$fname = $kaboom[0];
$exten = strtolower($fileExt);
$resized_file = "uploads/newimagename.ext"; //need to change this make sure you set the extension and file name correct.. you will want to secure things up way more than this too..
$wmax = 1500;
$hmax = 700;
img_resize($target_file, $resized_file, $wmax, $hmax, $exten);