public Function tuisongfile () {$this->display (); } public Function Wpull () {header (' Content-type:text/html;charset=utf8 '); $url = "Http://localhost/baoanwap/index.php/Home/Index/wpull"; Var_dump ($_files); Var_dump ($_files[' myateam_image ' [' tmp_name ']); exit; $ch = Curl_init (); $data = Array (' Path ' =>new \curlfile ($_files[' myateam_image ' [' tmp_name ']), ' img_type ' = ' png '); $data = Array (' path ' = = ($_files[' myateam_image '] [' tmp_name ']), ' img_type ' = ' png '); ' Myateam_image ' =>new \curlfile ($_files[' myateam_image ' [' tmp_name ']),//Picture successfully removed curl_setopt ($ch, Curlo Pt_url, $url); curl_setopt ($ch, curlopt_post,true); curl_setopt ($ch, Curlopt_postfields, $data); curl_setopt ($ch, curlopt_returntransfer,true); $result = curl_exec ($ch); Curl_close ($ch); echo $result; }
The above accepts the picture and then sends it to another server
Public Function Wpull () { $tmpname = $_files["path"] ["tmp_name"]; Print_r ($_files); exit (); Echo ' ===file upload info: '; Print_r ($_files[' path ' [' tmp_name ']); exit (); Move_uploaded_file ($_files["path" ["Tmp_name"], "./public/ceshi/"); $upload = new \think\upload ();//Instantiate upload class $upload->maxsize = 3145728;//Set attachment upload size //$upload Exts = Array (' jpg ', ' gif ', ' PNG ', ' jpeg ');//Set attachment upload type $upload->rootpath = './public/ Ceshi/'; Set the attachment upload root directory $upload->savepath = ";//Set Attachments upload (sub) directory if (! $upload->upload ()) {//Upload error message error messages //$this->error (); $this->error ($upload->geterror ()); } else{//upload successfully Gets the upload file information foreach ($info as $file) { echo $file [' Savepath ']. $file [' savename '] ; } }
thinkphp in curl accept the picture and upload it to the database