I have the below line of code which I am trying to use after an image is uploaded in order to resize the image.
I have confirmed my image does get uploaded correctly so the image file is in the correct location however I keep getting an error

The line of code I am trying to use is

$newwidth=60; 
$newheight=($height/$width)*$newwidth; 
$tmp=imagecreatetruecolor($newwidth,$newheight); 
imagecopyresampled($tmp,$atarget_path,0,0,0,0,$newwidth,$newheight, $width,$height);  

I confirmed the $atarget_path holds the correct value in the form of ./img/avatars/testone.jpg and when I go to that folder on my server I see the testone.jpg file . So I am not sure why I am getting the below error messgage

Warning: imagecopyresampled() expects parameter 2 to be resource, string given in /home/****/public_html/****/avatarupload.php on line 84

Any suggestions?
Thanks!!

Recommended Answers

http://php.net/imagecopyresampled

See the sample code. The error message states you are passing a string (targetpath), instead of an image.

Jump to Post

All 2 Replies

http://php.net/imagecopyresampled

See the sample code. The error message states you are passing a string (targetpath), instead of an image.

Ahh ya the string I am passing is the full file path to the image so like
home/public_html/img/testimg.jpg is what I am passing imagecopyresampled but guess I need to make it just be the image name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.