Dev Center
Table of contents

Thanks for Downloading Dynamic Web TWAIN 30-Day Trial!

Your download will start shortly. If your download does not begin, click here to retry.

Document Saving

How can I send additional form fields with images to my server or database?

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]);
  }
}

Is this page helpful?

YesYes NoNo

In this article:

latest version

    • Latest Version (18.4)
    • Version 18.3
    • Version 18.1
    • Version 18.0
    • Version 17.3
    • Version 17.2.1
    • Version 17.1.1
    • Version 17.0
    • Version 16.2
    • Version 16.1.1
    Change +