DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Rubin has posted 1 posts at DZone. View Full User Profile

Save any image from url using php

01.13.2013
| 7081 views |
  • submit to reddit
<?php
  $im=imagecreatefromjpeg('http://images.websnapr.com/?size=size&key=Y64Q44QLt12u&url=http://google.com');
    header('Content-type:image/jpeg');
    imagejpeg($im);
 ?>

The above code snippet saves image from url into our local file system.

imagecreatefromjpeg function is used for creating an image from file or URL

Also allow_url_fopen setting must be set to On in php.ini file for creating image resource from URL

For more details please refer the documentation mentioned in below url

http://php.net/manual/en/filesystem.configuration.php

Comments

Michael Molo replied on Thu, 2013/02/21 - 3:22am