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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:57:00+00:00 2026-06-01T07:57:00+00:00

Had this working; at one stage. The problem is the following text is now

  • 0

Had this working; at one stage. The problem is the following text is now appearing in the field for the image in the database “System.Web.HttpPostedFileWrapper”

the following code is from the controller:

  [HttpPost]
    public ActionResult Create(CarAdvert caradvert,
         HttpPostedFileBase picture1)
    {
        if (ModelState.IsValid)
        {

            if (picture1 != null)
            {
                string image1 = picture1.FileName;
                caradvert.Image1 = image1;
                var image1Path = Path.Combine(Server.MapPath("~/Content/Images"), image1);
                picture1.SaveAs(image1Path);
            }


             db.CarAdverts.Add(caradvert);
             db.SaveChanges();
             return RedirectToAction("Index");  
        }

This code is from the create view:

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

    @Html.ValidationSummary(true)
    <fieldset>
        <legend>CarAdvert</legend>
      <div class="editor-field">

        <input type="file" name="Image1" />
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
    }
  • 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-01T07:57:02+00:00Added an answer on June 1, 2026 at 7:57 am

    the paramater in the controller for HttpPostedFileBase has to have the same name as the input type=”file” . Either do:

    [HttpPost]     
    public ActionResult Create(CarAdvert caradvert,          
    HttpPostedFileBase Image1)
    

    or

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

    That should do it

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

Sidebar

Related Questions

Strangely I had this working before but I reinstalled my system, upgraded to w7
So, thought I had this working last night, couldve sworn it. Now it no
Ok this is a weird problem because I had it working before. So I
I had this working to spec, until the specs changed. This function is now
I am working on this problem and had previously asked related question. Implementation of
I had this working in an old code that I didn’t end up using...
I had this sqlcmd snippet working in batch but when I converted to powershell,
Has anyone else had this issue and found a working solution? I've enabled the
I've been working at this for two days and have not had much luck.
So basically this code was working fine before. I had some computer issues and

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.