0

i have an input control of type file.

<input id="FileUpload1" type="file" runat="server" size="35" />

there are four input controls like this and in aspx.cs file i m trying to make an array of these ids..

i have made an array

HtmlInputFile[] fl = new HtmlInputFile[4] { FileUpload1, FileUpload2, FileUpload3, FileUpload4 };

but it gives me an error..how can i get the value of these inputs.

3
  • What kind of error? Compiler error? Exception? Commented Nov 26, 2009 at 15:55
  • What are you trying to do ? I mean why do you need this array ? Do you need an ID array ? or control array ? and what exception do you get ? Commented Nov 26, 2009 at 15:56
  • when i try to get the filename through string filename = fl[i].PostedFile.FileName; it says object reference not set to an instance Commented Nov 26, 2009 at 15:58

1 Answer 1

1

The

FileUploadX.PostedFile 

Property is null if no file was uploaded. You need to check wether

FileUploadX.HasFile == true 

before attempting to access it.

In case you are using ASP.Net AJAX updatepanels, you'll run into all sorts of proplems with FileUpload. See Link for possible solutions

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.