Save image to local ins save picture according to picture address save image Save picture in Word saved image

Source: Internet
Author: User
function getimg ($url, $filename) {
if ($url = = ")
return false;
Turn on output control buffering
Ob_start ();
Reads the URL picture file and writes to the output cache
ReadFile ($url);
Returns the contents of the output buffer
$img = Ob_get_contents ();
Empty the contents of the output buffer
Ob_end_clean ();
Gets the content length obtained from the cache
$size = strlen ($img);
Picture Catalogue
$imgdir = './';
$fp = @fopen ($imdir. $filename, ' a ');
Fwrite ($fp, $img);
Fclose ($FP);
}
getimg (' http://ubmcmm.baidustatic.com/media/v1/0f000ntPpKn9AHLumTK7W6.jpg ', ' 1.jpg ');

The above describes the image according to the address, save the image to the local, including the preservation of pictures, image address aspects of the content, I hope that the PHP tutorial interested friends have helped.

  • 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.