Download pictures on the network to the local server using thinkphp

Source: Internet
Author: User

I use the thinkphp version is 3.2.3, this version of the earlier version of the call method is not the same, the correct way to call is:

Demo3controller.class

<?phpnamespace Home\controller; UseThink\controller;classDemo3controllerextendsController { Public functionDownload () {$url= "Http://n.sinaimg.cn/sports/20161023/MrD2-fxwztrt0212622.jpg"; $LOCALURL= "Public/bookcover/mrd2-fxwztrt0212622.jpg"; $http=New\org\net\http (); $http->curldownload ($url,$LOCALURL); Echo"Saved successfully"; }    }

$url is the remote address of the server

$LOCALURL is the local server address

Note here that the public/bookcover/directory does not exist, it is necessary to create a manual, or will error, the Curldownload method does not automatically create a local folder.

The pictures saved to the public directory can be accessed through http://localhost/thinkphp/Public/bookcover/MrD2-fxwztrt0212622.jpg.

Download pictures on the network to the local server using thinkphp

Related Article

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.