php--download images to local code

Source: Internet
Author: User

1<?PHP2 //get a picture of a webpage3 $url= "HTTP://QLOGO2.STORE.QQ.COM/QZONE/393183837/393183837/50";4 $curl= Curl_init ($url); Initializes a new session, returning a curl handle for use by the curl_setopt (), curl_exec (), and curl_close () functions. 5 $filename=Date("Ymdhis"). ". jpg; File name6curl_setopt ($curl, curlopt_returntransfer,1); Sets an option for the given Curl session handle. 7 $imageData= Curl_exec ($curl); Crawl the URL and pass it to the browser8Curl_close ($curl); Close the curl resource and shut down system resources9 $TP= @fopen($filename,' a '); The fopen () function opens the file or URL. Ten fwrite($TP,$imageData); The fwrite () function writes to the file (which is safe for binary files).  One fclose($TP); The fclose () function closes an open file.  A?>

To get the mesh, just fill in the path to download the picture.

php--download images to local code

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.