HTTPDownloadDirectly()

Description

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

Syntax

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

Parameters

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

bool

true indicates success. false indicates failure.

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

Remarks

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.

Example

/****Get ducument.txt from: http://www.dynamsoft.com/files/ducument.txt****/
/****Save as 01.txt to: D:/ ****/
DWObject.HTTPDownloadDirectly('www.dynamsoft.com','/files/ducument.txt','D:/01.txt');
/**Get image02.jpg from: http://www.dynamsoft.com/images/GetImage.aspx?Index=2&amp;Name=image02.jpg**/
/**Save as 02.jpg to: D:/temp/02.jpg**/
DWObject.HTTPDownloadDirectly('www.dynamsoft.com', '/images/GetImage.aspx?Index=2&amp;Name=image02.jpg','D:/temp/02.jpg');