httpUpload()

Description

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

Syntax

ImageViewerObject.io.httpUpload(url, indices, imageType [, httpMethod = EnumHttpMethod.POST, [dataFormat = EnumUploadDataFormat.BINARY]]);

Parameters

<string> url: specifies the absolute path of the action page and file name (optional).
<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

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

Return value

bool

true indicates success. false indicates failure.

When false is returned, please check getErrorCode() or getErrorString() and getHTTPResponse() for error information.

Remarks

EnumImageType, EnumHttpMethod and EnumUploadDataFormat is 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.

Example

var imageviewer = DCSObject.getImageViewer("******");  // Get a specified image viewer
imageviewer.io.httpUpload('https://www.dynamsoft.com/SaveToFile.aspx?filename=001.pdf', [0,1], imageviewer.io.EnumImageType.PDF, imageviewer.io.EnumHttpMethod.POST, imageviewer.io.EnumUploadDataFormat.BINARY);

See also

.io.httpUploadAsync()