/// <summary> /// Get a MIME info object based on a strongly typed version of file extensions /// </summary> /// <param name="extension">File extension to get a MIME type for</param> /// <returns>Hydrated MimeInfo or IndexOutOfRange exception</returns> public MimeInfo this[MimeExtension extension] { get { return(_extensionDictionary[extension]); } }
public ActionResult Upload(HttpPostedFileBase file) { try { var extension = MimeExtension.GetExtension(file.ContentType); var filePath = FileHelper.GetTempPath(); var mapPath = Server.MapPath(filePath); var fullName = FileHelper.CreateSafePath(mapPath, extension, out var name); file.SaveAs(fullName); return(Json(new AjaxResult { Status = true, Data = new UploadResult { Path = filePath, Name = name, FullName = $"{filePath}{name}" } })); } catch (Exception e) { return(Json(new AjaxResult(e.JoinMessages()))); } }