Dev Center
You can use SetHTTPFormField to set meta data as form fields and use HTTPUpload to send it to the server side with the scanned document.
// Clear old fields before adding new ones
DWObject.ClearAllHTTPFormField();
DWObject.SetHTTPFormField("FileType", "Insurance Doc");
You can check out this demo project for sending additional form fields when uploading the scanned document.
SetHTTPFormField can also be used to send image data in base64 or BLOB to the server side.
By design, the method HTTPUpload() only contains one file. But as it essentially sends an HTTP form to the server, you can attach multiple files in that form using the methods ConvertToBlob() and SetHTTPFormField() . Check out the following snippet on how it is done. NOTE that the method HTTPUpload() only has 3 parameters as it doesn’t need to specify a file anymore.
/**
* Upload the images specified by their indices in the specified file type as separate files.
* @param indices Specify the images
* @param type Specify the file type
*/
function uploadSeparateFiles(indices, type) {
var protocol = Dynamsoft.Lib.detect.ssl ? "https://" : "http://",
port = window.location.port === "" ? 80 : window.location.port,
actionPage = "/upload.aspx";
// path to the server-side script
var url = protocol + window.location.hostname + ":" + port + actionPage;
if (DWObject) {
var done = 0,
count = indices.length;
var toBlob = function (index) {
var fieldName = "SampleFile_" + index;
var fileName = fieldName + getExtension(type);
DWObject.ConvertToBlob(
[index],
type,
function (result, _indices, type) {
DWObject.SetHTTPFormField(fieldName, result, fileName);
done++;
if (done === count) {
DWObject.HTTPUpload(
url,
function () {
console.log("Success");
},
function (errCode, errString, responseStr) {
console.log(errString);
}
);
} else {
toBlob(indices[done]);
}
},
function (errorCode, errorString) {
console.log(errorString);
}
);
};
toBlob(indices[done]);
}
}
latest version