I'm trying to copy an image from a remote location. I created a function that takes in the file name ($fname) and the path of the image ($remote_path). Currently I'm running PHP 5.3.28 with the following code:
function copy_remote_image($fname, $remote_path){
$thumbWidth = 612;
$folder = 'uploads/photos/';
$img = imagecreatefromjpeg( $remote_path );
if($img){
$width = imagesx( $img );
$height = imagesy( $img );
// calculate thumbnail size
$new_width = $thumbWidth;
$new_height = floor( $height * ( $thumbWidth / $width ) );
// create a new temporary image
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
// copy and resize old image into new image
imagecopyresampled( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
// save thumbnail into a file
imagejpeg( $tmp_img, $folder.$fname,70 );
imagedestroy($tmp_img);
return true;
}else{
return false;
}
}
As of now the image is not copying and when I use var_dump on $img i get: resource(25) of type (gd)