How can I upload the acquired images to my Web server?

Dynamic .NET TWAIN supports the following upload methods: FTP, HTTP Put and HTTP Post. For information about these methods, please refer to:
HTTPUploadThroughPut
HTTPUploadThroughPost
FTPUpload
We recommend you use the HTTP Post method to upload images to web servers.
Below is a simple sample of uploading an acquired image as a PDF file.
Form1.cs:
-------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace Upload
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void btnScan_Click(object sender, EventArgs e)
        {
            dynamicDotNetTwain1.SelectSource();
            dynamicDotNetTwain1.OpenSource();
            dynamicDotNetTwain1.IfDisableSourceAfterAcquire = true;
            dynamicDotNetTwain1.AcquireImage();
        }
 
        private void btnUpload_Click(object sender, EventArgs e)
        {
            string strActionPage = "Upload.aspx";
            dynamicDotNetTwain1.HTTPUploadThroughPost("localhost", 0, strActionPage, "test.pdf");
            if (dynamicDotNetTwain1.ErrorCode != 0) {
                MessageBox.Show(dynamicDotNetTwain1.HTTPPostResponseString);
            }
        }
    }

Upload.aspx (Note: please deploy the file on the web server side)
-------------------------------

<%@ 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(".") + "/ImageScanned/" + uploadfile.FileName);
%>
Is this page helpful?

Leave a Reply

Your email address will not be published.