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