Asp.net Upload File Hasfile Always False
I need to know WHY my FileUpload control is returning the Hasfile flag as false. I am selecting a file but still it is false. Here it code for the. Hi, I have a problem with a FileUpload control. When try to I upload a file with it, HasFile always yields false. I was using it within an AJAX UpdatePanel, tried to do a full postback by using a T.
Definition
Gets a value indicating whether the FileUpload control contains a file.
Property Value
true
if the FileUpload contains a file; otherwise, false
.
Asp File Upload Code
Examples
The following example demonstrates how to create a FileUpload control that performs error checking. Before saving the file, the HasFile method is called to verify that the control contains a file to upload. In addition, the File.Exists method is called to check whether a file with the same name already occurs in the path. If it does, the name of the file to upload is prefixed with an underscore character before the SaveAs method is called. This prevents the existing file from being overwritten.
Remarks
Asp Upload File To Server
The HasFile property gets a value indicating whether the FileUpload control contains a file to upload. Use this property to verify that a file to upload exists before performing operations on the file. For example, before calling the SaveAs method to save the file to disk, use the HasFile property to verify that the file exists. If HasFile returns true
, call the SaveAs method. If it returns false
, display a message to the user indicating that the control does not contain a file.
Applies to
See also
File Upload Asp
- SaveAs(String)SaveAs(String)SaveAs(String)SaveAs(String)