thinkphp in curl accept the picture and upload it to the database

Source: Internet
Author: User
Tags curl

 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

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.