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 8008531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:10:00+00:00 2026-06-04T18:10:00+00:00

I have a form where I am uploading multiple files and there are a

  • 0

I have a form where I am uploading multiple files and there are a couple of textboxes and some checkboxes associated with each file being uploaded.
I have seen examples for uploading multiple files where the actionresult signature is something like this:

[HttpPost]
public ActionResult Upload(IEnumerable<HttpPostedFileBase> fileUpload)

However, I cant find any example where I can have multiple files uploaded where my actionresult signature is something like this:

[HttpPost]
public ActionResult Upload(MyViewModel vm)

The reason I want this viewmodel being posted is because I think its cleaner than using the FormCollection variable and because I want to each file being uploaded and the data added along with its associated textboxes to be grouped together by way of a List<FileUploadPacket> which will part of the ViewModel

UPDATE

My View model below:

public class EmployeeVM  
{

    public int EmployeeID {get ;set;}
    public string EmpName {get ;set;}
    //Other properties

    public List<FileUploadPacket> FileUploadPackets { get; set; }
}

The FileUploadPacket class which has the property of type HttpPostedFileBase

public class FileUploadPacket 
{

    public int FileID {get ;set;}
    public string UserEnteredDesc {get ;set;}
    //some more other properties

    public HttpPostedFileBase UpFile { get; set; }
}

Code snippet of my view.aspx as below

<%: Html.TextBoxFor(model => model.EmpName, new { maxLength = 50 })%>

Upload your files here: 
<input type="file" id="UpFile" name="UpFile" value="ActionHandlerForForm"  />
<%: Html.TextBoxFor(model => model.FileUploadPackets[0].UserEnteredDesc )%>

<input type="file" id="UpFile" name="UpFile" value="ActionHandlerForForm"  />
<%: Html.TextBoxFor(model => model.FileUploadPackets[1].UserEnteredDesc )%>

As you can see, I have all the other properties specific to this one file being uploaded kept in its own class. So that in my form an employee can enter his name and upload his files and provide some description and other details for each file. If I move the public HttpPostedFileBase UpFile { get; set; } property to the EmployeeVM class then I will have to collect all the files separately in an array and manually map a file to its description. Is there no way to do this keeping the UpFile property in the FileUploadPacket class itself?

I am using the aspx view engine.

Please help. Thanks for your time…

  • 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-04T18:10:01+00:00Added an answer on June 4, 2026 at 6:10 pm

    The fix to this is changing the way you Name and ID the upload control.

    <%: Html.TextBoxFor(model => model.EmpName, new { maxLength = 50 })%>
    
    Upload your files here: 
    <input type="file" id="FileUploadPackets[0].UpFile" name="FileUploadPackets[0].UpFile" value="ActionHandlerForForm"  />
    <%: Html.TextBoxFor(model => model.FileUploadPackets[0].UserEnteredDesc )%>
    
    <input type="file" id="FileUploadPackets[1].UpFile" name="FileUploadPackets[1].UpFile" value="ActionHandlerForForm"  />
    <%: Html.TextBoxFor(model => model.FileUploadPackets[1].UserEnteredDesc )%>
    

    This worked for me!! Hope it helps anyone else out there..

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

Sidebar

Related Questions

I have a very simple form for uploading a file. In the form, there's
I have a html form for uploading a file, which is as follows: $uploadhtml
I have form for file uploading in my website that i check mime-type of
I have a little problem with uploading multiple files in PHP , i have
I have a PHP form for uploading files and it works fine and displays
I have seen some PHP scripts for uploading files and images but didn't find
I have a form with flask-wtf for uploading images, also file field can be
I have a form with multiple fields, and each time the user changes a
I have form with web browser component, there is a button which triggers page
I have form, where some fields are looks like rows, so I can add/delete

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.