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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:42:45+00:00 2026-05-30T08:42:45+00:00

My first .Net/MVC project, I generated a view that allows me to list, edit,

  • 0

My first .Net/MVC project, I generated a view that allows me to list, edit, and create items in a database, and I would like to add a file upload control to the Create page, to just upload one file.

I understand that within [HttpPost] I need “public ActionResult Index(HttpPostedFileBase file)” but my current [HttpPost] is like this: “public ActionResult Create(lm_pics lm_pics)”.

  • 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-30T08:42:46+00:00Added an answer on May 30, 2026 at 8:42 am

    Why do you have 2 file inputs? Why do you have 2 forms? Isn’t the first form sufficient (assuming of course you add the enctype="multipart/form-data" attribute to it as you cannot upload files without it)?:

    @model PictureUploader_MVC.Models.lm_pics
    @{
        ViewBag.Title = "Create";
    }
    <h2>Upload Picture</h2>
    
    @using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" })) 
    {
        @Html.ValidationSummary(true)
        <fieldset>
            <legend>lmit_pics</legend>
            <div class="editor-label">
                @Html.LabelFor(model => model.brand)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.brand)
                @Html.ValidationMessageFor(model => model.brand)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.enabled)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.enabled)
                @Html.ValidationMessageFor(model => model.enabled)
            </div>
            <div>
                <label for="file">Filename:</label>
                <input type="file" name="file" id="file" />
            </div>
        </fieldset>
    
        <button type="submit">Create</button>
    }
    
    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>
    

    and your controller action that will process the form submission:

    [HttpPost]
    public ActionResult Create(lm_pics lm_pics, HttpPostedFileBase file)
    {
        ...    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am embarking upon my first ASP.NET MVC project and I would like to
I'm working on my first real ASP.NET MVC project and I've noticed that the
I have a new ASP.NET MVC project (my first), and I had been running
I'm just starting my first project in ASP.NET MVC. In my webforms experience, I
I'm working on an asp.net-mvc project. I have an Items table and a Tags
I have an existing ASP.Net MVC project that is using entities / repositories in
I'm doing my first ASP.NET MVC 3 project here, and since I need to
I'm using Entity Framework 4 Code First in my .net MVC 2.0 project and
I have an ASP.NET MVC 3 project that I just created using the project
im doing my first asp.net MVC project here, i need to be able to

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.