Web Demos

BARCODE READER SDK DEMO

Explore the flexibe barcode reading settings to optimize for your specific usage scenario.

WEB TWAIN SDK DEMO

Try the most popular web scanner features: scan images, import local images and PDF files, edit, save to local, upload to database, and etc.

BARCODE READER JAVASCRIPT DEMO

Transform any camera-equipped devices into real-time, browser-based barcode and QR code scanners.

MRZ SCANNER WEB DEMO

Detects the machine-readable zone of a passport, scans the text, and parses into human-readable data.

APP STORE DEMOS

BARCODE READER SDK FOR IOS

BARCODE READER SDK FOR ANDROID

VIEW MORE DEMOS >
Dev Center
Table of contents

Document Saving

How to upload multiple files at a time?

Scenario:

After scanning multiple files, you might want to upload them one by one as individual images. Before version 13.1, you have to call the upload method(s) multiple times. From version 13.1+, you can do this in one go.

Solution:

You can use the methods ConvertToBlob and HTTPUpload to achieve this.

Steps:

  1. In JS, write code similar to the following:
    function UploadAsJPG() {
     var count = 0;
     DWObject.ClearAllHTTPFormField();
     DWObject.SetHTTPFormField("UploadedImagesCount",DWObject.HowManyImagesInBuffer);
    
     function asyncFailureFunc(errorCode, errorString) {
         alert("ErrorCode: " + errorCode + "\r" + "ErrorString:" + errorString);
     };
    
     var onEmptyResponse = function () {
         console.log("Uploaded Successfully");
     };
    
     var onServerReturnedSomething = function (ecode,estring,resp) {
         console(resp);
     }
    
     var convertImage = function (_index) {
         DWObject.ConvertToBlob(
             [_index], 
             Dynamsoft.DWT.EnumDWT_ImageType.IT_JPG,
             function (result) {
                 DWObject.SetHTTPFormField('image_' + _index, result, 'JPG_image_' + _index);
                 count++;
                 if (count < DWObject.HowManyImagesInBuffer) {
                     convertImage(count);
                 } else {
                     DWObject.HTTPUpload("http://localhost:90/saveUploadedJPG.aspx", onEmptyResponse, onServerReturnedSomething);// Please replace the URL with yours.
                 }
             }, 
             asyncFailureFunc
         );
     };
    
     convertImage(0);
    }
    
  2. On the server, add an action page to process the uploaded data, take c# as an example,
    <%@ Page Language="C#" %>
    <%
     try
     {
         String strImageName;
         String strInfo = HttpContext.Current.Request["UploadedImagesCount"];
         short uploadedImagesCount = Convert.ToInt16(strInfo);
         HttpFileCollection files = HttpContext.Current.Request.Files;
         for (short i = 0; i < uploadedImagesCount; i++)
         {
             HttpPostedFile uploadfile = files["image_" + i.ToString()];
             strImageName = uploadfile.FileName;
        
             uploadfile.SaveAs(Server.MapPath(".") + "\\UploadedImages\\" + strImageName + ".jpg");
         }
     }
     catch
     {
     }
    %>
    

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 +