Downloads an file from the HTTP server directly without opening it in Dynamic Web TWAIN.


.HTTPDownloadDirectly(hTTPServer, hTTPRemoteFile, localFile, [optionalAsyncSuccessFunc, optionalAsyncFailureFunc]);


<string> hTTPServer: specifies the HTTP server.
<string> hTTPRemoteFile: specifies the path of the file on the HTTP server, or path to an action page (with necessary parameters) which gets and sends back the file stream to the client.
<string> localFile: specifies the local path for the downloaded file.

The following two parameters are optional. If either one exists or both exist, the method is asynchronous, otherwise it's synchronous.

<OnSuccess function> optional optionalAsyncSuccessFunc: callback function triggered when the file is downloaded successfully.
<OnFailure function> optional optionalAsyncFailureFunc: callback function triggered when the file failed to be downloaded.

Please refer to the function prototype OnSuccess or OnFailure.

Return value

Only valid when used synchronously.


true indicates success. false indicates failure.

When false is returned, check ErrorCode or ErrorString for error information.


Technically this method can download any file from the HTTP server.

If you want to use this method to upload / download files through HTTPS, please don't forget to set IfSSL to true and set the correct HTTPPort.


/****Get ducument.txt from:****/
/****Save as 01.txt to: D:/ ****/
/**Get image02.jpg from:**/
/**Save as 02.jpg to: D:/temp/02.jpg**/
DWObject.HTTPDownloadDirectly('', '/images/GetImage.aspx?Index=2&Name=image02.jpg','D:/temp/02.jpg');
Is this page helpful?

Leave a Reply

Your email address will not be published.