|
|
|
|
[Home][27 ImageHunt ][27.7 Step 2]
|
|
27.7 Step 2. Upload ImageAdd the following to the form so it will look like Figure 27.1:
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. |