The fileupload control enables you to upload file to the server. It displayed a text control and a browse button that allow users to select a file upload to the server.
This control is used to upload any type of file . but we can set it only specific format of file , using some code writing behind it .
html code of file upload control in asp.net
<asp:FileUpload ID="FileUpload1" runat="server" />
The asp.net fileupload control is introduce in asp.net 2.0 framework that provides the advanced functionality to the users to sent a file from their computer to the online web server.
The security feature of file upload control does not allow , you to specify the file path dynamically and users are also not allowed to type-in the file path in the text box field available with file upload control in asp.net. Users have to browse the file using file-navigation dialog box to select it for uploading.
Tha asp.net fileupload control provides different types of properties that enable you to examine the characteristics of the uploaded file and save it to a specific location on the web server.
fileBytes :- it provides the access to the bytes array generated from the stream of file selected by the user to upload.
FileContent:- it provides the Sysmte.IO.Stream object that points to the file specified for uploading. You access all the methods and properties stream class that allows you to read or write the bytes array stream of the file that is being upload by the fileupload control.
FileName :- it returns the name of the file selected by the user to upload using fileuplaod control.
SaveAs :- the saveas method of it provides the functionality to save the uploaded file at the location specified in the code to write it in the server .
PostedFile :- the postedFile provides as object of httpPostedFile class that points to the single file that have been upload using FileUpload control. It provides the access to the properties such as ContentLength, ContentType, FileName, InputStream and SaveAs method.
The asp.net FIleUpload control caches the entire contents of the elected file from client’s computer system to the the server memory after finishing the caching process it move forward to execute the code specified in the web page.