Dynamic Web TWAIN: How to send meta data with scanned images to server?

Dynamic Web TWAIN provides many methods for uploading images to the server through post. Sometimes you might want to send more information to the server together with the image data. In this case, you can use the method SetHTTPFormField which was added in version 5.0 of Dynamic Web TWAIN.

To use this method, you should first clear all pre-defined form fields with the method ClearAllHTTPFormField. Also, please use SetHTTPFormField before you use any of the HTTPUpload***ThroughPost*** methods.

Here is an example in JavaScript:

DWObject.ClearAllHTTPFormField();
DWObject.SetHTTPFormField("PDFFileName", "test.pdf");
//Get action page path
var CurrentPathName = unescape(location.pathname); 
var CurrentPath = CurrentPathName.substring(0, CurrentPathName.lastIndexOf("/") + 1);
var strActionPage = CurrentPath + "SaveToFile.aspx";
DWObject.HTTPUploadAllThroughPostAsMultiPageTIFF(
  "www.dynamsoft.com",
  strActionPage,
  "test.tiff"
);

In the action page, you can access the uploaded fields with their names. For example, in C#, you can access it like this:

System.Web.HttpContext.Current.Request.Form["PDFFileName"];
Is this page helpful?

Leave a Reply

Your email address will not be published.