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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:59:54+00:00 2026-05-28T03:59:54+00:00

This is a follow-up question to ASP.NET MVC 3 – File Upload . I

  • 0

This is a follow-up question to ASP.NET MVC 3 – File Upload. I have a URL syntax that I cannot change. I need to upload files to a URL in the syntax of “/person/{personID}/files”. Currently, I am trying the following:

index.html

<form action="/person/2/files" method="post" enctype="multipart/form-data">
    <div>Please choose a file to upload.</div>
    <div><input id="fileUpload" type="file" /></div>

    <div><input type="submit" value="upload" /></div>
</form>

The personID parameter value is dynamically populated when the form loads. Regardless, when I click “upload”, I’m posting back to the following action:

UploadController.cs

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UploadFile(int uniqueID)
{
  foreach (string file in Request.Files)
  {
    // Request.Files is empty
  }

  return View();
}

How do I POST both a collection of files AND a parameter using the URL syntax of “/person/{personID}/files”? I know this is a very specific request. I have run out of time on my project and I’m totally confused why the approach I’m using doesn’t work. Can somebody please help me?

Thank you so very much.

  • 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-05-28T03:59:55+00:00Added an answer on May 28, 2026 at 3:59 am

    Assuming you have a route defined for this custom url:

    routes.MapRoute(
        "Upload",
        "person/{uniqueid}/files",
        new { controller = "Upload", action = "UploadFile" }
    );
    

    you just need to give your file input a name:

    <div><input id="fileUpload" type="file" name="file" /></div>
    

    Also I would recommend you to use action arguments instead of looping through Request.Files:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult UploadFile(int uniqueID, HttpPostedFileBase file)
    {
        return View();
    }
    

    and if you wanted to post multiple files:

    <div><input type="file" name="files" /></div>
    <div><input type="file" name="files" /></div>
    <div><input type="file" name="files" /></div>
    ...
    

    use a collection:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult UploadFile(int uniqueID, IEnumerable<HttpPostedFileBase> files)
    {
        return View();
    }
    

    You might also find the following blog post useful.

    Or even better, use a view model:

    public class MyViewModel
    {
        public int UniqueID { get; set; }
        public IEnumerable<HttpPostedFileBase> Files { get; set; }
    }
    

    and then:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult UploadFile(MyViewModel model)
    {
        return View();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow-up question to ASP.NET How to pass container value as javascript
this is a follow-up question of mine. Suppose now I have a URL :
I'm trying to ensure that visitors of my ASP.NET MVC website always have the
My question is as follows: I have a base controller (ASP.Net MVC controller) called
I have a custom asp.net mvc class validation attribute. My question is how can
I have a site that was using ASP.Net MVC Beta 5, and I have
Just a general question, I'm developing an ASP.NET MVC 3 web application that reads
Using VB.NET on this one, in ASP.NET Web Forms. I have a property that
I'm working with ASP.NET 3.5 SP1 and I have a question that I've been
This is a follow up to a previous question that I had before about

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.