Regarding fileupload control

Posted by Tdhivamca under ASP.NET on 11/2/2010 | Points: 10 | Views : 1393 | Status : [Member] | Replies : 2
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



Responses

Posted by: Raja on: 11/2/2010 [Member] Starter | Points: 25

Up
0
Down
You can download the articles sample from http://www.dotnetfunda.com/articles/article981-multiple-files-upload-in-aspnet-and-aspnet-with-jquery-.aspx and see how it is working. Hopefully that will help you.

Thanks

Regards,
Raja, USA

Tdhivamca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vpramodg on: 11/3/2010 [Member] Starter | Points: 25

Up
0
Down
hai

The code is working properly here.

pramod.v.g

Tdhivamca, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response