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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:29:22+00:00 2026-06-03T17:29:22+00:00

This is my upload Action : [HttpPost] public ActionResult addcar(Models.vehicule model) { ViewBag.cat =

  • 0

This is my upload Action :

[HttpPost]
    public ActionResult addcar(Models.vehicule model)
    {
        ViewBag.cat = new SelectList(entity.categorie, "Idcat", "Nom");
        ViewBag.mark = new SelectList(entity.marque, "id", "nom");      
        if (ModelState.IsValid)
        {
// Upload Function begin
            var destinationFolder = Server.MapPath("/Content/Vpic");
            foreach (string name in Request.Files)
            {
                HttpPostedFileBase postedFile = Request.Files[name];
                if (postedFile.ContentLength > 0)
                {
                    var fileName = model.Matv;
                    var path = Path.Combine(destinationFolder, fileName + ".jpg");
                    postedFile.SaveAs(path);
                }
            }
// upload function end

            model.Idag = User.Identity.Name.ToString();
            entity.vehicule.AddObject(model);
            entity.SaveChanges();
            TempData["Resultat"] = "L'ajout de véhicule a reussi";
            return RedirectToAction("GesV", "Agence");
        }
        else
            return View();

    }

And this is my view :

 <% using (Html.BeginForm("addcar", "Agence", FormMethod.Post, new { @class = "search_form", @enctype = "multipart/form-data" }))

I have used this same function already in other code it works fine here i dont know whi it dosen’t work, The reste of action works fine but the photo is not uploaded

  • 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-03T17:29:28+00:00Added an answer on June 3, 2026 at 5:29 pm

    What does your View look like? Are you including the atribute enctype = “multipart/form-data” on your form tag in the view?

    Verify @ sign, not needed on enctype

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

Sidebar

Related Questions

How can I upload files to server using JSP/Servlet? I tried this: <form action="upload"
I have this html form <form action=upload/ id=upload name=upload> // other form data </form>
For a file upload I have the action below. This creates a dir with
I've got a model like this def upload_location(instance, filename): return 'validate/%s/builds/%s' % (get_current_user(), filename)
I'm trying to draw a cuboid with css (like this http://upload.wikimedia.org/wikipedia/commons/d/dc/Cuboid.png but ONLY 3
I'm uploadig my package to PyPi with this command: python setup.py sdist upload This
I have one website, not i want when i upload this site on live
I have one audio file captured from my iphone. I want to upload this
I try this command to upload a file (standard.xml) into table book the file
my problem is this: I should upload a project on SVN server to put

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.