public JsonResult UpLoadCompanyLogo() { var CompanyLogoFile = HttpContext.Request.Files.Get("CompanyLogoFile"); JsonResult json = new JsonResult() { ContentType = "text/html" }; if (CompanyLogoFile != null) { string[] allowType = new string[] { "image/gif", "image/png", "image/jpeg" }; if (!allowType.Contains(CompanyLogoFile.ContentType)) { json.Data = new { Status = false, Message = "请上传gif,png,jpg格式图片" }; return(json); } if (CompanyLogoFile.ContentLength > (1024 * 1024 * 2)) { json.Data = new { Status = false, Message = "文件不能超过2M" }; return(json); } var CompanyLogoPath = "/UpLoadFiles/SysAgentCompanyLogo/" + this.BasicAgent.Id + "_" + CompanyLogoFile.FileName; string ThumbnailPath = string.Format("/UpLoadFiles/{0}/{1}", "SysAgentCompanyLogo", "Thu_" + this.BasicAgent.Id + "_" + CompanyLogoFile.FileName); var savePath = HttpContext.Server.MapPath(CompanyLogoPath); var ThumbnailSavePath = HttpContext.Server.MapPath(ThumbnailPath); // 服务器端缩略图路径 CompanyLogoFile.SaveAs(savePath); ImageUpload.MakeThumbnail(savePath, ThumbnailSavePath, 210, 71, "HW"); json.Data = new { Status = true, Message = "", Result = ThumbnailPath, }; return(json); } else { json.Data = new { Status = false, Message = "请选择上传文件" }; return(json); } }