C# Upload & Retrieve image in Asp.Net MVC

11
21



Description :

This is step by step tutorial on how to Upload images and how to display images back to the browser in Asp.Net Mvc 5 Application using sql Server Database.

Nguồn:https://wijstaanvooronzegrondrechten.org/

11 COMMENTS

  1. public ActionResult Create(resim resim, HttpPostedFileBase file)

    {

    if (file !=null)

    {

    string rsm = System.IO.Path.GetFileName(file.FileName);

    string adres = Server.MapPath("~/images/"+resim);

    file.SaveAs(adres);

    resim.ad = Request.Form["ad"];

    resim.resim1 = rsm;

    }

    if (ModelState.IsValid)

    {

    db.resim.Add(resim);

    db.SaveChanges();

    return RedirectToAction("Index");

    }

    ViewBag.ilanid = new SelectList(db.ilan,"id","baslik",resim.ilan_id);

    ViewBag.islem_id = new SelectList(db.islem, "id", "ad");

    ViewBag.kategori_id = new SelectList(db.kategori, "id", "ad");

    ViewBag.kimden_id = new SelectList(db.kimden, "id", "ad");

    return View(resim);

    }

  2. Hi Vetrivel..Thanks for making this video.But when run view action method why we need to pass the id parameter.Why it not retrieve the id. Do we need to pass the id parameter everytime when run the view.

LEAVE A REPLY

Please enter your comment!
Please enter your name here