Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shaz3e/433a6ac9aa5701cf3802 to your computer and use it in GitHub Desktop.
Save Shaz3e/433a6ac9aa5701cf3802 to your computer and use it in GitHub Desktop.
Download & save a remote image on your server
Downloading an image on a remote server and saving it on your own server is useful when building websites, and it’s also very easy to do. The two lines of code below will do it for you.
<?php
$image = file_get_contents('http://www.url.com/image.jpg');
file_put_contents('/images/image.jpg', $image); //Where to save the image
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment