In the last appIOS real-name authentication using the thinkphp write interface, you must upload a picture of yourself. How can I use thinkphp to write the upload image? Is there any source code? Please note every step. Thank you !! You must upload an image of your own for real-name authentication using the thinkphp write interface of the latest IOS app.
Thank you very much for every step of writing source code to upload images using thinkphp !!
Reply content:
You must upload an image of your own for real-name authentication using the thinkphp write interface of the latest IOS app.
Thank you very much for every step of writing source code to upload images using thinkphp !!
// The upload image method can be placed in the parent class for future inheritance and direct calling
// Two upload Methods: file and base64
Public function picupload () {if (! IS_POST) {die ('');} // base64 upload mode (mainly for processing input file not supported) $ smeta =$ _ POST ['smeta ']; if (preg_match ('/^ (data: \ s * image \/(\ w +); base64,)/', $ smeta, $ result )) {// base64 upload $ data = base64_decode (str_replace ($ result [1], '', $ smeta); $ dataname = '. /Uploads /'. uniqid (). '. '. $ result [2]; if (file_put_contents ($ dataname, $ data) {$ this-> ajaxoutput ($ dataname ); // The returned data structure is self-encapsulated} else {$ this-> ajaxerror ('upload error ');} // Process file Upload. Here we call thinkphp to encapsulate \ Think \ Upload. You can learn how to write the thinkphp official class. $ config = array ('rootpath' => '. /Uploads/', 'savepath' => '', 'maxsize' => 11048576, 'savename' => array ('uniqid ',''), 'exts' => array ('jpg ', 'gif', 'png', 'jpeg '), 'autosub' => false ,); $ upload = new \ Think \ Upload ($ config); // $ info = $ upload-> upload (); // start to upload if ($ info) {// uploaded successfully $ first = array_shift ($ info); if (! Empty ($ first ['url']) {$ url = $ first ['url'];} else {$ url = C ("tmpl_parse_string.w.upload __"). $ first ['savename'];} $ this-> ajaxoutput ($ url);} else {// Upload Failed, returned error $ this-> ajaxerror ($ upload-> getError ());}}
App post
And then $ _ FILES in php receive, there is no special