Try the following:
<?php $path = "uploads/"; $img = $_FILES['photoimg']['tmp_name']; $dst = $path . $_FILES['photoimg']['name']; if (($img_info = getimagesize($img)) === FALSE) die("Image not found or not an image"); $width = $img_info[0]; $height = $img_info[1]; switch ($img_info[2]) { case IMAGETYPE_GIF : $src = imagecreatefromgif($img); break; case IMAGETYPE_JPEG : $src = imagecreatefromjpeg($img); break; case IMAGETYPE_PNG : $src = imagecreatefrompng($img); break; default : die("Unknown filetype"); } $tmp = imagecreatetruecolor($width, $height); imagecopyresampled($tmp, $src, 0, 0, 0, 0, $width, $height, $width, $height); imagejpeg($tmp, $dst.".jpg"); ?>
source share