How to save a binary file (image) from url address
The following script allows to download and save a binary file from specific url address. The Microsoft HTTP request
technology is used in this script in order to download the binary file from url
address. The Ado
technology is used for saving the contents of the file to disk. Both technologies are launched by the CreateObject
An example of download and save of image generated by web camera:
The script can be included into the application for example into the objects PmTimer
Dim oHttp, sUrl, sSavePath, oStream
sUrl = "http://www.harrachtour.cz/img_cam.jpg"
oHttp.Open "GET", sUrl, false ', "username", "password" 'username and password only if proxy server
oHttp.setRequestHeader "Content-Type", "image/multipart"
If oHttp.readyState = 4 And oHttp.status = 200 Then
oStream.type = 1 '1=adTypeBinary
oStream.savetofile sSavePath, 2 '2=adSaveCreateOverWrite, 1=adSaveCreateNotExist