Download images to your website

Posted By: Ian on Mar 28, 2012 in PHP, Snippets
Last modified on December 9th, 2012 at 9:35 pm,

Download images to your website from another site.

Linking to images is fine if there on your site but not necessarily a good thing if there on someone else’s.
Because for one the site owner of the other site can change the image, alter the size or even delete it. Why this might not be important for some people it is to me and for my Banner Bar program as the banners are 125px by 125px and just recently one company changed there 125 banner to a half banner which made the bar look very messy. Yea yea i should of defined the image sizes but that’s the point sometimes you forget but anyway this is why i’m sharing this script which when you insert your link to an image it will download it to your site which for the next version of Banner Bar will be very useful.

The script is well commented but basically it works like this

  • Insert URL to image link in the input field and click submit
  • Downloads image to your site using CURL
  • Renames it by adding the time to the front (Salt could be added for more security)
  • Checks to make sure it is an image and if not deletes it.

This script uses PHP, Ajax and Jquery so the page does not need refreshing, as soon as you hit submit the script sends the image URL to process.php then process.php sends the result back.

Download image to website

If your wanting to secure your image folder a little more you could use a proxy script to take the image from the image folder and serve it through PHP thus hiding the location of the actual image which ideally should be outside the document root. You can download example here
If you want more information on securing uploads see for some valuable tips.

Update: upload/download image script

Following on from this post we go too Which is a full script for downloading and uploading images to your site


Did this help you? Please Let me know by commenting below even if it’s just to say “Thanks”

leave a comment

About This Site

Dreams are built from lines of code well it's true!
If you can dream it you can usually code it.

I have learned so much from other people on the Internet and this site is for me to give back some of what i have learned and hope people can now learn from me.
Have fun and surf safely,

protected by copyscape duplicate content check


Powered by Banner Bar 125