Uploads images of specified indices in Dynamsoft image viewer to the HTTP server asynchronously .

Syntax, indices, imageType, onHttpUploadSuccess, onHttpUploadFailure[, onHttpUploading = null[, httpMethod = EnumHttpMethod.POST [, dataFormat = EnumUploadDataFormat.BINARY]]]));


<string> url: specifies the name of the http server and action page and filename. For example “”
<int[]> indices: specifies the indices of images in buffer. The index is 0-based.
<EnumImageType> imageType: specifies the format of the file you want to upload as.

Image Type Enumerated Value
BMP EnumImageType.BMP
JPEG EnumImageType.JPEG
TIFF EnumImageType.TIFF
PNG EnumImageType.PNG
PDF EnumImageType.PDF

<onHttpUploadSuccess function> onHttpUploadSuccess: callback function triggered when the file is uploaded successfully.
<onHttpUploadFailure function> onHttpUploadFailure: callback function triggered when the file failed to be uploaded.
<onHttpUploading function> optional onHttpUploading: callback function triggered during uploading image.
<EnumHttpMethod> optional HttpMethod: specifies the uploading method, either EnumHttpMethod.POST or EnumHttpMethod.PUT.
<EnumUploadDataFormat> optional dataFormat: specifies the data format, either EnumUploadDataFormat.BINARY or EnumUploadDataFormat.BASE64.

Please refer to the function prototype onHttpUploadSuccess or onHttpUploadFailure or onHttpUploading.

Return value



EnumImageType, EnumHttpMethod and EnumUploadDataFormat are under namespace io.

If imageType is EnumImageType.BMP/JPEG/PNG, the length of indices must be 1.

EnumHttpMethod.PUT is not supported in version 5.0 and 5.1.

For IE 9 or lower, even if you set data format to EnumUploadDataFormat.BINARY, this setting will be ignored and the image will be automatically uploaded as BASE64 format.


var imageviewer = DCSObject.getImageViewer("******");  // Get a specified image viewer"", [0,1],, onHttpUploadSuccess, onHttpUploadFailure, onhttpdownloading,,;

function onHttpUploadSuccess (httpResponse) {
    console.log("HTTPResponseString: " + httpResponse);

function onHttpUploadFailure (errorCode, errorString, httpResponse) {
    console.log("ErrorCode: " + errorCode+ "ErrorString: " + errorString + "HTTPResponseString: " + httpResponse);

function onhttpdownloading (percentage) {


See also



Is this page helpful?

Leave a Reply