时间:2021-07-01 10:21:17 帮助过:21人阅读
public function upload(){ $path = "/uploads/news/" . date("Ymd");$extArr = array("jpg", "png", "gif");if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){ $name = $_FILES['photoimg']['name']; $size = $_FILES['photoimg']['size']; if(empty($name)){ echo '请选择要上传的图片'; exit; }// echo "here1";exit(); // echo $name;exit(); $ext = hhhh($name); echo "here2";exit(); if(!in_array($ext,$extArr)){ echo '图片格式错误!'; exit; } if($size>(5*1024*1024)){ echo '图片大小不能超过5M'; exit; } $image_name = time().rand(100,999).".".$ext; $tmp = $_FILES['photoimg']['tmp_name']; if(move_uploaded_file($tmp, $path.$image_name)){ echo ''; }else{ echo '上传出错了!'; } exit;} }//获取文件类型后缀 // public function indexpublic function hhhh($file_name){ echo "here1";exit(); $extend = pathinfo($file_name); $extend = strtolower($extend["extension"]); return $extend;}
$ext = $this->hhhh($name);
$ext = $this->hhhh($name);