php设置上传图片的大小

来源:互联网 发布:vue.js 教程 pdf 编辑:程序博客网 时间:2024/06/05 07:35
  $upload_file   =   my.".".$file_ext; 
$upload_path=$dir."/".$upload_file;   //定义文件最终的存储路径和名称
if(is_uploaded_file($upload_tmp_file) )
{
if(move_uploaded_file($upload_tmp_file,$upload_path)){

list($width_orig, $height_orig) = getimagesize($upload_path);
if ($width_orig>61||$height_orig>61) {
$image_p = imagecreatetruecolor(61, 61);
if($piece[1]=="jpg"||$piece[1]=="jpeg"){
$image = imagecreatefromjpeg($upload_path);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 61, 61, $width_orig, $height_orig);
imagejpeg($image_p,$upload_path);
}else if($piece[1]=="gif"){
$image = imagecreatefromgif($upload_path);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 61, 61, $width_orig, $height_orig);
imagegif($image_p,$upload_path);
原创粉丝点击