Working with FileUpload Control
This will show you how to access FileUpload properties programmatically and how to save a file selected by FileUpload control.
Hi All,
FileUpload control is used to allow user to select and upload single file at desired location. This control contains textbox and Browse button.
This control can be represented as
Lets take a example. Suppose you have web page and fileupload control is added to it. In addition add a button control to submit the file to web server via postback.
Protected Button1_Click(ByVal sender as Object, Byval e as System.EventArgs) handles Button1.Click
If (FileUpload1.hasfile) then
'Suppose you have lable control to display information of selected file
Label1.Text = "File Length: " + FileUpload1.FileBytes.Length.ToString() _
+ "" + "File Name:" + FileUpload1.FileName _
+ "MIME Type" + FileUpload1.PostedFile.ContentType
FileUpload1.SaveAs (MapPath([Path] + FileUpload1.FileName))
Else
Label1.Text = "No File Received."
End if
End Sub
Hope this is of help.
Cheers
Shilpa