HTTPUploadAllThroughPostAsMultiPageTIFF()

Description

Uploads all the images in Dynamic Web TWAIN viewer to the HTTP server as a TIFF file.

Syntax

.HTTPUploadAllThroughPostAsMultiPageTIFF(hTTPServer, actionPage, fileName, [optionalAsyncSuccessFunc, optionalAsyncFailureFunc]);

Parameters

<string> hTTPServer: specifies the name of HTTP server. For example: "www.dynamsoft.com", "localhost", "127.0.0.1".
<string> actionPage: specifies the relative path for the action page. The action page will receive and process the uploaded image stream. See code snippet.
<string> fileName: specifies the file name.

[HTML5 edition only]The following two parameters are optional. If either one exists or both exist, the method is asynchronous, otherwise it's synchronous.

<OnHttpUploadSuccess function> optional optionalAsyncSuccessFunc: callback function triggered when the file is uploaded successfully.
<OnHttpUploadFailure function> optional optionalAsyncFailureFunc: callback function triggered when the file failed to be uploaded.

Please refer to the function prototype OnHttpUploadSuccess or OnHttpUploadFailure.

Return value

Only valid when used synchronously.

bool

true indicates success. false indicates failure.

When false is returned, check ErrorCode or ErrorString for error information.

Remarks

If you want to use this method to upload / download files through HTTPS, please don't forget to set IfSSL to true and set the correct HTTPPort.

See Also

TiffCompressionType

Example

The sample shows how to upload all the scanned image as a mutilpage TIFF.

JavaScript:

function btnScan_onclick() 
{
    if (DWObject) {
        DWObject.SelectSource();
        DWObject.OpenSource();
        DWObject.IfDisableSourceAfterAcquire = true;
        DWObject.AcquireImage();
    }
}
// OnHttpUploadSuccess and OnHttpUploadFailure are callback functions.
function OnHttpUploadSuccess() {
    console.log('successful');
}
function OnHttpUploadFailure(errorCode, errorString, sHttpResponse) {
    alert(errorString + sHttpResponse);
}
function btnUpload_onclick() 
{
    var strHTTPServer = location.hostname; //The name of the HTTP server. 
    var CurrentPathName = unescape(location.pathname);
    var CurrentPath = CurrentPathName.substring(0, CurrentPathName.lastIndexOf(&quot;/&quot;) + 1);
    var strActionPage = CurrentPath + &quot;SaveToFile.aspx&quot;;
    DWObject.IfSSL = false; // Set whether SSL is used
    DWObject.HTTPPort = location.port == &quot;&quot; ? 80 : location.port;
    // Upload all the images in Dynamic Web TWAIN viewer to the HTTP server as a TIFF file asynchronously
    DWObject.HTTPUploadAllThroughPostAsMultiPageTIFF(
      strHTTPServer,
      strActionPage,
      &quot;imageData.tif&quot;,
      OnHttpUploadSuccess,
      OnHttpUploadFailure
    );
}

SaveToFile.aspx:

&lt;%
    try{
        String strImageName;
        HttpFileCollection files = HttpContext.Current.Request.Files;
        HttpPostedFile uploadfile = files[&quot;RemoteFile&quot;];
        strImageName = uploadfile.FileName;
        uploadfile.SaveAs(Server.MapPath(&quot;.&quot;) + &quot;\\UploadedImages\\&quot; + strImageName);
    }
    catch{
	}
%&gt;