- Here's the Scenario
- Accepting User Uploads in a Nutshell
- A Demo Application
- Summary
A Demo Application
This section describes a demo application that accepts user uploads. Figure 2 shows the application. You can test the demo application at http://www.aspnet-solutions.com/UploadTest/WebForm1.aspx.
Figure 2 This application takes a user-specified file and shows information about it.
Listings 12 show the code that places the file information into the user interface. Listing 1 shows the C# code; Listing 2 shows the VB code.
Listing 1C# Code for Placing File Information into a User Interface Label Object
private void DoIt_Click(object sender, System.EventArgs e) { FileInfo.Text = "File name: " + Filename.PostedFile.FileName + "<br>\r\n" + "File size: " + Filename.PostedFile.ContentLength + "<br>\r\n" + "File type: " + Filename.PostedFile.ContentType; }
Listing 2VB code for Placing File Information into a User Interface Label Object
Private Sub DoIt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DoIt.Click FileInfo.Text = _ "File name: " + Filename.PostedFile.FileName + "<br>" + vbCrLf + _ "File size: " + Filename.PostedFile.ContentLength + "<br>" + vbCrLf + _ "File type: " + Filename.PostedFile.ContentType End Sub
The C# and VB projects can be downloaded from http://www.aspnet-solutions.com/InformITArticles/LeineckerArticle003_Projects.zip.