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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:37:14+00:00 2026-05-23T13:37:14+00:00

I have gotten this semi autogenerated code, but I am uncertain where the Post

  • 0

I have gotten this semi autogenerated code, but I am uncertain where the Post data is saved and how I access the variables in my controller so I can validate and upload it to my database.

    @model FirstWeb.Models.Picture

@{
    ViewBag.Title = "Upload et billede";

}

<h2>Upload et billede</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>



@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>

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

        <div class="editor-label">
            @Html.LabelFor(model => model.Title)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Title)
            @Html.ValidationMessageFor(model => model.Title)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ConcertYear)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ConcertYear)
            @Html.ValidationMessageFor(model => model.ConcertYear)
        </div>

        <p>
            <input type="submit" value="Upload" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Tilbage til billeder", "Index")
</div>
  • 1 1 Answer
  • 2 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-23T13:37:15+00:00Added an answer on May 23, 2026 at 1:37 pm

    It seems that you are trying to upload files here. Checkout the following blog post. You will need to use a multipart/form-data enctype for your form in order to be able to upload files. So the first step is to fix your form definition:

    @using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" })) 
    {
        ...
    }
    

    then update your view model so that it takes the uploaded file as property:

    public class Picture
    {
        public HttpPostedFileBase File { get; set; }
        public string Title { get; set; }
        public int ConcertYear { get; set; }
    
        ... some other properties used in the view
    }
    

    and and finally have your controller POST action take this view model as parameter:

    [HttpPost]
    public ActionResult Foo(Picture model)
    {
        if (!ModelState.IsValid)
        {
            // there were validation errors => re-display the view
            return View(model);
        }
    
        // the model is valid at this stage => check if the user uploaded a file
        if (model.File != null && model.File.ContentLength > 0)
        {
            // the user uploaded a file => process it ...
        }
        ...
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have gotten this to work a bit but can't seem to figure out
I'm sure this is very simple. I have gotten colorbox to work before, but
I have gotten this to work nicely, but when speed hits a certain speed
Real Dumb question. I figured I would have gotten this straight by now, but
After putzing around some, I have gotten this code to work to show me
I have a list of System.DirectoryServices.ActiveDirectory.Domain objects gotten via this method. How do I
I have tried for three days now and gotten nowhere on this.... I absolutely
I have gotten this error when setting the -Xcheck:jni option, and calling my native
How do I use named captures when performing Regex.Replace? I have gotten this far
Within my project I have gotten this error: Error 1 The type or namespace

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.