I made a file that is in charge of uploading images, this images are then moved to a folder in the server. I think I can't resize the image directly in the $_FILES array so I think I must resize the image after being in the server, so my question is, how can I resize images that are in the server?
This is part of the code I have:
//This is after getting target which is the file saved on the server
move_uploaded_file($_FILES[$str]['tmp_name'], $target);
scale_image($target);
Now the function scale_image()
function scale_image($image)
{
if(!empty($image)) //the image to be uploaded is a JPG I already checked this
{
$source_image = imagecreatefromjpeg($image);
$source_imagex = imagesx($source_image);
$source_imagey = imagesy($source_image);
$dest_imagex = 300;
$dest_imagey = 200;
$image = imagecreatetruecolor($dest_imagex, $dest_imagey);
imagecopyresampled($image, $source_image, 0, 0, 0, 0,
$dest_imagex, $dest_imagey, $source_imagex, $source_imagey);
}
}
But this doesn't seems to work, it moved the file but not resized.