HTTPUpload

Description

1. Uploads images of specified indices in Dynamic Web TWAIN viewer to the HTTP server asynchronously.

2. Or uploads the form created by SetHTTPFormField.

Syntax

1 .HTTPUpload(url, indices, enumImageType, dataFormat, asyncSuccessFunc, asyncFailureFunc);

2 .HTTPUpload(url, asyncSuccessFunc, asyncFailureFunc);

Parameters

<string> url: specifies the name of http server and action page and filename. For example "www.dynamsoft.com/ActionPageName?filename=FileName"
<int[]> indices: specifies the indices of images in buffer. The index is 0-based. If EnumDWT_ImageType is IT_BMP/IT_JPG/IT_PNG, since multi-page file is not possible, you can only specify one index.
EnumDWT_ImageType enumImageType: specifies the format of the file you want to upload as.

Type Numeric Value
IT_BMP 0
IT_JPG 1
IT_TIF 2
IT_PNG 3
IT_PDF 4

EnumDWT_UploadDataFormat dataFormat: specifies the data format, either EnumDWT_UploadDataFormat.Binary or EnumDWT_UploadDataFormat.base64.

Type Numeric Value
BINARY 0
BASE64 1

<onHttpUploadSuccess function> asyncSuccessFunc: callback function triggered when the file is uploaded successfully.
<onHttpUploadFailure function> asyncFailureFunc: callback function triggered when the file fails to be uploaded.

Please refer to the function prototype OnHttpUploadSuccess or OnHttpUploadFailure.

Return value

bool

This method is used asynchronously only. Even though it returns true doesn't mean that the upload is successful. When upload fails, check ErrorCode or ErrorString for error information.

Remarks

This method is valid only in HTML5 Edtion (Windows & Mac)

Example

JavaScript:

DWObject.HTTPUpload ('www.dynamsoft.com/SaveToFile.aspx?filename=001.pdf', [0,1],  EnumDWT_ImageType.IT_PDF, EnumDWT_UploadDataFormat.Binary, OnHttpUploadSuccess, OnHttpUploadFailure);
function OnHttpUploadSuccess (httpResponse) {
    console.log("HTTPResponseString: " + httpResponse);
}
function OnHttpUploadFailure (errorCode, errorString, httpResponse) {
    alert("ErrorCode: " + errorCode+ "ErrorString: " + errorString + "HTTPResponseString: " + httpResponse);
} 

See also

How to upload multiple files at a time

SetUploadSegment

For more information about how to upload large images with segments, please refer to this KB article.

Is this page helpful?

Leave a Reply

Your email address will not be published.