Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8765307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:14:53+00:00 2026-06-13T16:14:53+00:00

Let me try to explain my situation as simple as possible first: Suppose I

  • 0

Let me try to explain my situation as simple as possible first:

Suppose I have a page which contains multiple [input type=’File’]. Some of them may be selected a file and some are not.

In my httppost method, I know I need to use parameter like “IEnumerable files” to get filenames, and also each [input] name I should define either = ‘files’ or ‘files[0]’,’files[1]’, etc…..

My question is: when getting a list of HttpPostedFileBase, how could I determine which file belongs to which input control? As some inputs may leave blank.

Also because these [input] are created dynamically and there is no fixed number of it, I could not hard-code the parameter in httppost method for each of them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:14:54+00:00Added an answer on June 13, 2026 at 4:14 pm

    Try this solution:

    View:

    @using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        <input type="file" name="file1" />
        <input type="file" name="file2"/>
        <input type="file" name="file3"/>
        <input type="file" name="file4"/>
        <input type="file" name="file5"/>
    
        <input type="submit" value="go" />
    }
    

    Controller:

      var uploaded = Request.Files.AllKeys
          .Select(x => new {file = Request.Files[x], name = x})
                .Where(x => x.file.ContentLength > 0).ToList();
    

    The “uploaded” anonymouse type will contains file belonging to input control name, and will conatins only input names which selected

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me try and explain the scenario: I have a form with multiple items
OK, this is impossible, but I will try to explain the situation here. Let's
Let me try to explain the situation the best I can. Lets say I
Let me try to explain my challenge. I'm building a Silverlight app which will
Okay let me try to explain this.. So i have a player, that can
Let me try to explain this the best I can. I have a component
Let me try to explain what the situation is as thoroughly as I can
Let me explain the situation before I ask the question. I have a site,
Let me try to explain what I have on view and what's I'm trying
Let me try to explain My case, I have two table and each of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.