我只是上传:
$path =“uploads /”;
$actual_image_name = time().$session_id.".".$ext; $tmp = $_FILES['photoimg']['tmp_name']; move_uploaded_file($tmp,$path.$actual_image_name);
试试这个:
<?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,$width,$height,$height); imagejpeg($tmp,$dst.".jpg"); ?>