PHP中无法调用控制器

WBOY
Release: 2016-06-23 13:17:47
Original
984 people have browsed it

我在页面用异步上传,准备上传图片

页面中是直接调用到控制下的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;}
Copy after login



是我得把这段代码写成一个类吗?还是可以放到一个控制器中


回复讨论(解决方案)

$ext = $this->hhhh($name);

$ext = $this->hhhh($name);




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template