Unable to call controller in PHP

Source: Internet
Author: User
PHP cannot call the controller. I use asynchronous upload on the page to prepare to upload images.

The page directly calls the upload function under the control, and then the upload function calls another hhhh function, but the jump fails all the time. with the breakpoint test, it will not jump into the upload function at all, the log prompts 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 'select the image to upload'; exit ;} // echo "here1"; exit (); // echo $ name; exit (); $ ext = hhhh ($ name); echo "here2"; exit (); if (! In_array ($ ext, $ extArr) {echo 'image format error! '; Exit;} if ($ size> (5*1024*1024) {echo 'image size cannot exceed 5 MB'; exit;} $ image_name = time (). rand (100,999 ). ". ". $ ext; $ tmp = $ _ FILES ['photoimg '] ['tmp _ name']; if (move_uploaded_file ($ tmp, $ path. $ image_name) {echo '';} an error occurred while uploading else {echo! ';} Exit ;}/// obtain the file type suffix // public function indexpublic function hhhh ($ file_name) {echo "here1"; exit (); $ extend = pathinfo ($ file_name); $ extend = strtolower ($ extend ["extension"]); return $ extend ;}



Do I have to write this code into a class? You can still put it in a controller.


Reply to discussion (solution)

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

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.