我在页面用异步上传,准备上传图片
页面中是直接调用到控制下的upload功能,然后upload功能再调用一个hhhh的功能,但是一直跳转不成功,用断点测试,根本就跳不进upload这个功能,日志提示 PHP Fatal error: Call to undefined function hhhh() in D:\wamp\apps\p1weixin\Cms\Lib\Action\Wap\NewsAction.class.php on line 156
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 '<img src="'.$path.$image_name.'" class="preview" alt="PHP中无法调用控制器" >'; }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);