Friday 28 February 2014

Save an image from URL using php


save an image from URL then save it into a directory php Iam Explain about how to save an image form External URL,It is very simple using following code
<?php
  $imageurl ='http://sri-knowledgecorner.rhcloud.com/images/blogicon.jpeg';

  $image=file_get_contents($imageurl);
 
  $imagename = basename($imageurl);//image name
 
  define('DIRECTORY', 'images/'); //save image in images folder

  file_put_contents(DIRECTORY.$imagenam, $image);
?>
Make sure that you have write permission to the directory where you want to store the image.