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 );