The leading provider of version control solutions and TWAIN SDKs
  • Contact us









HTTPUploadThroughPost Method

Description

Uploads the image of a specified index in buffer to the HTTP server through HTTP POST method.

ActiveX Edition Plug-in Edition Mac Edition
Since V4.0 Since V4.0 Since V6.4

Syntax

Boolean ObjectName. HTTPUploadThroughPost(String HTTPServer, Short sImageIndex, String ActionPage, String FileName)

Parameters

String HTTPServer: the name of the HTTP server.

Short sImageIndex: specifies the index of image in buffer. The index is 0-based. 

String ActionPage: the specified page for posting image files. This is the relative path of the page, not the absolute path. For example: "upload.asp", not "http://www.webserver.com/upload.asp". This is the page corresponds to the action in <form> html tag: <form id = "frmSample" action = "upload.asp" method = post>...</form>

String FileName: the name of the image to be uploaded.

Return value

Boolean.

TRUE indicates success. FALSE indicates failure.

When an error occurs and IfThrowException property is TRUE, an exception will be thrown.

When FALSE is returned or an exception is thrown, check ErrorCode property and ErrorString property for error information.

Remarks

Dynamic Webcam processes the image format according to the extension of the FileName.

Dynamic Webcam supports the following types of image files:

Bitmap *.bmp, *.dib
JPEG *.JPG, *.JPEG, .*.JPE, *.JFIF
TIFF *.TIF, *.TIFF
PNG *.PNG
PDF *.PDF

The field name of the uploaded image is RemoteFile.

IMPORTANT: Dynamic Webcam uses a special way to see if an image is uploaded and processed successfully by server. If the server returns 0 bytes, indicates success. Otherwise, indicates failure. In other words, when the uploaded image is processed successfully, the action page on the server should not return anything, even the "<HTML>".

See also

FTPUserName property, FTPPassword property, FTPPort property, ProxyServer property, FTPDownload(), FTPUpload(), HTTPPort property, IfSSL property, HTTPUserName property, HTTPPassword property, HTTPDownload(),, HTTPUploadThroughPut()

Sample

ASP.NET (C#) Sample:

Snippet in Scan.aspx:
...

<script language="javascript" type="text/javascript">
Webcam = document.getElementById("iDynamicWebcam");//iDynamicWebcam is the id of the Dynamic Webcam on the page (An object or an embed).
function btnScan_onclick() 
{
	Webcam.SelectSource();
	Webcam.OpenSource();
	Webcam.AcquireImage();
}
function btnUpload_onclick() 
{
	var strActionPage;
	var strHostIP;

	var CurrentPathName = unescape(location.pathname); // get current PathName in plain ASCII 
	var CurrentPath = CurrentPathName.substring(0, CurrentPathName.lastIndexOf("/") + 1); 
	strActionPage = CurrentPath + "SaveToFile.aspx"; //the ActionPage's file path

	strHostIP = "localhost"; //The host's IP or name 

	Webcam.HTTPPort = 80; 
	Webcam.HTTPUploadThroughPost(strHostIP,0,strActionPage,"imageData.tif");

	if (Webcam.ErrorCode != 0)
		alert(Webcam.ErrorString);
	else //succeded
		alert("Image Uploaded successfully");
} 
</script>

...

SaveToFile.aspx:
<%@ Page Language="c#" AutoEventWireup="false" Debug="True"%>

<%
	HttpFileCollection files = HttpContext.Current.Request.Files;
	HttpPostedFile uploadfile = files["RemoteFile"];
	uploadfile.SaveAs(System.Web.HttpContext.Current.Request.MapPath(".") + "/" + uploadfile.FileName);
%>