This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public ActionResult Upload(HttpPostedFileBase file) | |
{ | |
string fileName = System.IO.Path.GetFileName(file.FileName); | |
string path = System.IO.Path.Combine(Server.MapPath("~/Images"), fileName ); | |
if (IMAGE_FILE_TYPES.Contains(Path.GetExtension(file.FileName).ToUpperInvariant()) && file.ContentLength <= MAX_FILE_SIZE) | |
{ | |
file.SaveAs(path); | |
string base64Image = Convert.ToBase64String(System.IO.File.ReadAllBytes(path)); |