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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

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

Post 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';
			}
			
		}
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

$destimg is not defined.
Post Reply