function File_Upload($file,$path){ $max_file_size=100000000; $uptypes=array('image/jpeg','image/png','image/gif','image/jpg'); if (!is_uploaded_file($file['tmp_name'])) { echo "图片不存在!"; exit; } if($max_file_size < $file["size"]) { echo "文件太大!"; exit; } if(!in_array($file["type"], $uptypes)) { echo "文件类型不符!".$file["type"]; exit; } if(!file_exists($path)) { mkdir($path); } $filename=$file["tmp_name"]; $pinfo=pathinfo($file["name"]); $ftype=$pinfo['extension']; $pathname=time().".".$ftype; $destination = $path."/".$pathname; $res=move_uploaded_file ($filename, $destination); if($res) { return G_SITE_BASE."/business/images/".$pathname; } return "图片上传失败"; }
php 图片上传
最新推荐文章于 2022-11-13 02:33:33 发布