title: File Upload and save in Blazor Server Side
body: <p>How upload and save file in Database Using <code>HttpPostedFileBase</code> in Blazor</p>
  
  <pre class="lang-cs prettyprint-override"><code>    [HttpPost]
      public ActionResult Index(HttpPostedFileBase postedFile)
      {
          byte[] bytes;
          using (BinaryReader br = new BinaryReader(postedFile.InputStream))
          {
              bytes = br.ReadBytes(postedFile.ContentLength);
          }
          FilesEntities entities = new FilesEntities();
          entities.tblFiles.Add(new tblFile
          {
              Name = Path.GetFileName(postedFile.FileName),
              ContentType = postedFile.ContentType,
              Data = bytes
          });
          entities.SaveChanges();
          return RedirectToAction("Index");
      }
  
  </code></pre>