Hi
fileupload control always thows null exception error hough we have selected any files.
I have used both asp.net file upload control as well htlm file type contorl.
both are not taking any file even if we selected any file it always throws null exception error
I have used below codes
html code
<INPUT type=file id=File1 name=File1 runat="server" />
.CS code
if ((this.File1.PostedFile != null) && (this.File1.PostedFile.ContentLength > 0))
{
string fn = System.IO.Path.GetFileName(this.File1.PostedFile.FileName);
}
and have tried below code also
<asp:FileUpload ID="ImgUpload1" Width="400px" Height="22px" runat="server" />
cs code
if (Path.GetFileName(ImgUpload1.FileName.ToString()).ToString().Trim().Length > 0|| ImgUpload1.HasFile)
{
strpath = Path.GetFileName(ImgUpload1.FileName.ToString());
}
can you please any let me know the reason why its throwing null exception?
-
Dhivakaran T