Bildupload Codefehler

rernanded

Erfahrenes Mitglied
PHP:
<?php

if(isset($_POST['Submit'])) {

	$filedir = 'uploads_tests/'; // the directory for the original image
	
	$maxfile = '2000000';
	
	
	$userfile_name = $_FILES['image']['name'];
	$userfile_tmp = $_FILES['image']['tmp_name'];
	$userfile_size = $_FILES['image']['size'];
	$userfile_type = $_FILES['image']['type'];
	
	if (isset($_FILES['image']['name'])) 	{
		$prod_img = $filedir.$userfile_name;

	  move_uploaded_file($userfile_tmp, $prod_img);
	
		$sizes = getimagesize($prod_img);

		if ($sizes[1] <= $size)   {
			$new_width = $sizes[0];
			$new_height = $sizes[1];
		}

		$destimg=ImageCreateTrueColor($new_width,$new_height)
			or die('Problem in creating image.');

		$srcimg=ImageCreateFromJPEG($prod_img)
			or die('Problem in opening source image.');

		if(function_exists('imagecopyresampled'))	{
			imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
			or die('Problem in resizing image.');

		}else{
			Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
			or die('Problem in resizing image.');

		}
		ImageJPEG($destimg,$prod_img,90)
			or die('Problem in saving image.');

		imagedestroy($destimg);
	}

	echo '
	<a href="'.$prod_img.'">
		<img src="'.$prod_img.'" width="'.$new_width.'" height="'.$new_height.'">
	</a>';

}else{

	echo '
	<form method="POST" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data">
	<input type="file" name="image"><p>
	<input type="Submit" name="Submit" value="Submit">
	</form>';
}

?>
Hallo,
ich teste gerade einen Code zum Bilduploaden. Leider gibts da einen Fehler für den ich partout nicht die Lösung finde.
Mir wird immer der Alert 'Problem in creating image.' angezeigt.
Was mache ich falsch bei $new_width und $new_height? Oder liegts woanders?

MONI
 
Hi

imagecreatetruecolor hat gesagt.:
Depending on your PHP and GD versions this function is defined or not. With PHP 4.0.6 through 4.1.x this function always exists if the GD module is loaded, but calling it without GD2 being installed PHP will issue a fatal error and exit. With PHP 4.2.x this behaviour is different in issuing a warning instead of an error. Other versions only define this function, if the correct GD version is installed.
Deine Versionen und installierte Sachen sind...?
 

Neue Beiträge

Zurück