View Single Post
Old Nov 7th, 2007, 11:53 PM   #6
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Downloading an external image and saving it to disk

There are operations for accessing an external web page internally. You could do this with raw sockets even if you have to (Connect to the server, Request the image, Receive the image, Cast some black magic).

Make sure to use the correct header information to request the image (GET /myimage.jpg HTTP/1.1\r\nHost: mywebsite.com\r\nContent-type: image/jpeg\r\n\r\n), and then use your file IO functions (Open File, Write to File, What the hell does this do?) with a binary write stream to save the image locally.

Then, of course, automate this with an hourly crontab.

Last edited by Sane; Nov 8th, 2007 at 12:06 AM.
Sane is offline   Reply With Quote