public JsonResult UploadAircraftDocument([FromForm] AircraftFile document) { string uploadedFileName = string.Empty; byte[] fileBytes = null; string fileExt = null; if (document.File.Length != 0) { using (var ms = new MemoryStream()) { document.File.CopyTo(ms); fileBytes = ms.ToArray(); } fileExt = document.File.FileName.Substring(document.File.FileName.LastIndexOf('.')); uploadedFileName = _aircraftService.SaveDocument(fileBytes, fileExt); } return(new JsonResult(new { fileName = uploadedFileName })); }