title: Uploaded Image cant Edit in edit view
body: <p>Im make The Image Uploaded Create Controller are really working and  save the image for DB, Update are working but not replace image, alwyas display uplaoded image in grid view, please help me , how can i fix it? thanks </p>
  
  <p><strong>Create - Controller</strong></p>
  
  <pre><code>  public ActionResult Save(Component component, HttpPostedFileBase file)
      {   
          string fileName = string.Empty;
          if (file != null &amp;&amp; file.ContentLength &gt; 0)
          {
              // extract only the fielname
              fileName = Path.GetFileName(file.FileName);
              // store the file12 inside ~/App_Data/uploads folder
              var path = Path.Combine(Server.MapPath("~/Uploaded"), fileName);
              file.SaveAs(path);
          }
  
          var objContext = new KnittingdbContext();
          component.CreateBy = 1;
          component.StatusChangeDate = System.DateTime.Now;
          component.CreatedDate = System.DateTime.Now;
          component.EditBy = 1;
          component.EditDate = System.DateTime.Now;
          //file name added here
          component.FileName = fileName;  
          objContext.Components.Add(component);
          objContext.SaveChanges();
  
          TempData["Success"] = "Saved Sucessfully";
  
          return RedirectToAction("ComponentIndex", new { A = "New" });
      } 
  
  
  
  
  
  
  public ActionResult FileName(string id)
  {
      byte[] image = { };
  
      try
      {
          image = System.IO.File.ReadAllBytes(Server.MapPath("~/Uploaded/") + id);
      }
      catch { }
  
      return File(image, "image/png");
  }
  </code></pre>
  
  <p>My <strong>Update Controller</strong>:</p>
  
  <pre><code> public ActionResult Update(Component component, HttpPostedFileBase file)
          { 
              string fileName = string.Empty;
              if (file != null &amp;&amp; file.ContentLength &gt; 0)
              {
                  // extract only the fielname
                  fileName = Path.GetFileName(file.FileName);
                  // store the file12 inside ~/App_Data/uploads folder
                  var path = Path.Combine(Server.MapPath("~/Uploaded"), fileName);
                  file.SaveAs(path);
  
  
                  var objContext = new KnittingdbContext();
                  //blog.Id = 1;
                  objContext.Components.Attach(component);
                  var obJBlog = objContext.Entry(component);
  
                  obJBlog.Property(a =&gt; a.ComponentCode).IsModified = true;
                  obJBlog.Property(a =&gt; a.ComponentName).IsModified = true;
                  obJBlog.Property(a =&gt; a.Remarks).IsModified = true;
                  obJBlog.Property(a =&gt; a.StatusId).IsModified = true;
  
  
  
                  objContext.SaveChanges();
  
                  TempData["SuccessEdit"] = "Saved Sucessfully";
  
                  return RedirectToAction("ComponentIndex");
              }
              else
              {
                  return PartialView("_ComponentEdit", component);
              }
          }
  </code></pre>
  
  <p><strong>Update View</strong></p>
  
  <pre><code>&lt;div class="row" style="width:350px; margin-top:15px; margin-left:-10px;"&gt;
          @using (Html.BeginForm("Update", "Component", FormMethod.Post, new { enctype = "multipart/form-data" }))
          {
  
              &lt;div class="col-md-6" style="font-family:Arial, Helvetica, sans-serif; font-size:13px;"&gt;&lt;b&gt;Component Code&lt;/b&gt;&lt;b style=" color:#ff0000;"&gt;*&lt;/b&gt;&lt;/div&gt;
  
              &lt;div class="col-md-6"&gt;
                  @Html.TextBoxFor(a =&gt; a.ComponentCode, new { @maxlength = "5", Class = "form-control", style = "width:175px; height:25px;font-size:small;", onkeyup = "return validateChar(this)", @readonly = "readonly" })
                  &lt;div id="fname_error" style="margin-left:180px; width:140px;     top:5px; color:green; position:absolute; font-family:'Arial Unicode MS'; font-size:small;"&gt;&lt;/div&gt;
                  @Html.ValidationMessageFor(a =&gt; a.ComponentCode)
              &lt;/div&gt;
              &lt;div class="col-md-6"&gt;&lt;/div&gt;    &lt;div class="col-md-6"&gt;&lt;/div&gt;
      &lt;div class="col-md-6" style="font-family:Arial, Helvetica, sans-serif; font-size:13px;margin-top:5px;"&gt;
         &lt;b&gt; Component&lt;/b&gt;&lt;b style=" color:#ff0000;"&gt;*&lt;/b&gt;
      &lt;/div&gt;
              &lt;div class="col-md-6"&gt;
                  @Html.TextBoxFor(a =&gt; a.ComponentName, new { @maxlength = "15", Class = "form-control", style = "width:175px; height:25px;margin-top:6px;font-size:small;" })
                  @Html.ValidationMessageFor(a =&gt; a.ComponentName)
              &lt;/div&gt;            &lt;div class="col-md-6"&gt;&lt;/div&gt;    &lt;div class="col-md-6"&gt;&lt;/div&gt;
  
          &lt;div class="col-md-6" style="font-family:Arial, Helvetica, sans-serif; font-size:13px;"&gt;
             &lt;b&gt; Remarks&lt;/b&gt;
          &lt;/div&gt;&lt;div class="col-md-6"&gt;&lt;/div&gt;    &lt;div class="col-md-6"&gt;&lt;/div&gt;
              &lt;div class="col-md-6"&gt;
                  @Html.TextBoxFor(a =&gt; a.Remarks, new { Class = "form-control", style = "width: 250px; height: 65px; resize: none;margin-top:4px;font-size:small;  " })
              &lt;/div&gt;            &lt;div class="col-md-6"&gt;&lt;/div&gt;    &lt;div class="col-md-6"&gt;&lt;/div&gt;
      &lt;div class="col-md-6" style="font-family:Arial, Helvetica, sans-serif; font-size:13px;"&gt;
          &lt;b&gt;Status&lt;/b&gt;
      &lt;/div&gt;
  
              &lt;div class="col-md-6"&gt;
                  @Html.CheckBoxFor(a =&gt; a.StatusId)
              &lt;/div&gt;
  
              &lt;div class="col-md-6"&gt;
                  @Html.HiddenFor(a =&gt; a.ComponentId)
              &lt;/div&gt;
              &lt;div class="col-md-6"&gt;&lt;/div&gt;    &lt;div class="col-md-6"&gt;&lt;/div&gt;
              &lt;div class="col-md-6"&gt;
                  &lt;input type="submit" value="Update" class="btn btn-success" /&gt;
              &lt;/div&gt;
  
  
  
      &lt;div&gt;&lt;input type="file" name="file" id="file" /&gt; &lt;/div&gt;
  
  
          }
      &lt;/div&gt;
  </code></pre>