Page 1 of 1

Warning: imagecopyresampled(): supplied argument is not a va

Posted: Sun May 21, 2006 11:37 am
by psychotomus
I get this error when trying to resize an image after uploading it.

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /mounted-storage/home16a/sub002/sc18478-RGIJ/www/admin_wallpapers.php on line 196
Problem In resizing

Code: Select all

if ($_FILES["file"]["name"] <> "")
	{
		$file = strtolower($_FILES["file"]["name"]);
		$file_size = 1;
		if (stristr($file,".jpg") == TRUE )
		{
			$result = mysql_query( "SELECT * FROM wallpapers ORDER by id DESC" );//
			$row=mysql_fetch_array($result);	//Store Record Of Data in $row 
	
			$row=mysql_fetch_array($result);
			$loc = $row['id'] + 1;
			
			if (move_uploaded_file($_FILES["file"]["tmp_name"], "./wallpapers/" .  $loc . '.jpg'))
			{


				//SAVE THUMBNAIL
				$srcimg = imagecreatefromjpeg ("./wallpapers/" .  $loc . '.jpg') 
					or die ("Problem In opening Source Image");  // For JPEG 

				imagecopyresampled ($destimg,  $srcimg, 0, 0, 0, 0, 150, 150, imagesx($srcimg) , imagesy($srcimg)) 
					 or die ("Problem In resizing");  // Resample the image from $srcimg to the $destimg 
				
				imagejpeg ($destimg, "./wallpapers_thumbs/" . $loc . ".jpg") or die("Problem In saving");  // Save JPG
				$thumb = true;
	
				$filename = $loc . ".jpg";
				$result2 = mysql_query( "SELECT * FROM wallpaper_cats WHERE id = '$catid'" );//
				$row2=mysql_fetch_array($result2);	//Store Record Of Data in $row 
				$cat_name = $row['cat_name'];
				mysql_query("INSERT into wallpaperse(cat_id, cat_name, author, title, url, submitter,views, file_size, file_name, aprove, thumb) VALUES ('$cat', '$cat_name', '$author', '$title', '$url', '$user_id','0','$file_size', '$filename','n', '$filename')") or die("SELECT Error: ".mysql_error());
			}
			else
			{
				print 'error uploading file';
			}
			
		}

Posted: Sun May 21, 2006 9:06 pm
by Ambush Commander
$destimg is not defined.