Question : Using ASP to check if a graphic exists on an external site and download it if it exists

I have an ASP script on domain http://www.domain1.com

I have a library of JPG files on domain http://www.domain2.com

I need the ASP script to:
1. Check to see if http://www.domain2.com/1234.jpg exists.
2. If it does, download it and save it to the hard drive on http://www.domain1.com.

Is this possible? I don't necessarily need all the code written for me, just need to conceptualize how this might be possible. Thank you!

Answer : Using ASP to check if a graphic exists on an external site and download it if it exists

> I just get a 404 error

Sort of. Use the .Status property of the "Microsoft.XMLHTTP" object to see if you get an error. If .Status = 200, the image is available, if the .Status = 404 then it is not on the server. Other values can indicate other situations like "unauthorized" (401).

> Is it possible to download the contents of the file into a JPG on my local drive?

Yes. You need to capture it as a binary file. Use "ADODB.Stream" to capture the binary stream and write it to your hd.


Random Solutions  
 
programming4us programming4us