27.7 Step 2
About1 Introduction2 Image Recognition3 TransApplet4 API5 Interface6 Input7 Image Display8 Preprocessing9 Processing10 Normalization11 Parameter Class12 Image Signatures13 Unsupervised Filters14 BioFilters15 NeuralFilters16 Dynamic Library17 NeuralNet Filter18 Parameters19 Input Options20 Database Input21 Video Input22  Live Video Input23  Counting & Tracking24  Counting 25  Batch Job26 ImageFinder for DOS27 ImageHunt 28 Support Packages

27.1  Why ImageHunt? 
27.2  Design 
27.3 Web Server 
27.4 Install 
27.5 Web Project 
27.6 Step 1 
27.7 Step 2 
27.8 Step 3 
27.9 DOS Class 
27.10 Step 4 
[Home][27 ImageHunt ][27.7 Step 2]

 

27.7   Step 2. Upload Image

Add the following to the form so it will look like Figure 27.1:

  •    Upload button
  •    Search button
  •    TextBox
  •    Error message label

Double click the �Submit� button and enter:

        private void Submit1_ServerClick(object sender, System.EventArgs e)

            {

            if( ( File1.PostedFile != null ) && ( File1.PostedFile.ContentLength > 0 ) )

                {

                string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);

                SaveLocation = Server.MapPath("Data") + "\\" +  fn;

            

            Session [ "theFileName" ] = SaveLocation;

                string displayLocation =  dataPath + "\\" +  fn;

                try

                {

                    File1.PostedFile.SaveAs(SaveLocation);

                    Label2.Text = "Upload file to: " + displayLocation;

         

                    Image2.ImageUrl = displayLocation;

                    TextBox2.Text =

        System.IO.Path.GetFileName(File1.PostedFile.FileName);

                }

                catch ( Exception ex )

                {

                    Label2.Text = "Error: " + ex.Message;

                }

                }

            else

                {

                    Response.Write("Please select a file to upload.");

                }

         

            }

First of all, the following code makes sure a valid image has been selected:

        if( ( File1.PostedFile != null ) && ( File1.PostedFile.ContentLength > 0 ) )

                {

                �

        }

            else

                {

                    Response.Write("Please select a file to upload.");

                }

The following code finds the image name from the client�s computer and creates the path for this image on the server:

        string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);

                SaveLocation = Server.MapPath("Data") + "\\" +  fn;

The following code uploads the file:

                try

                {

                    File1.PostedFile.SaveAs(SaveLocation);

                }

                catch ( Exception ex )

                {

                    Label2.Text = "Error: " + ex.Message;

                }

 

[Home][About][1 Introduction][2 Image Recognition][3 TransApplet][4 API][5 Interface][6 Input][7 Image Display][8 Preprocessing][9 Processing][10 Normalization][11 Parameter Class][12 Image Signatures][13 Unsupervised Filters][14 BioFilters][15 NeuralFilters][16 Dynamic Library][17 NeuralNet Filter][18 Parameters][19 Input Options][20 Database Input][21 Video Input][22 Live Video Input][23 Counting & Tracking][24 Counting ][25 Batch Job][26 ImageFinder for DOS][27 ImageHunt ][28 Support Packages]

Copyright (c) 2006 - 2007 Attrasoft. All rights reserved.

gina@attrasoft.com