public ActionResult UpLoadImage() { HttpFileCollectionBase files = HttpContext.Request.Files; if (files == null || files[0] == null) { return(Success("请选择上传文件")); } HttpPostedFileBase file = files[0]; //效验图片格式 int code = QiNiuUpLoadApplication.CheckUpFileFixByImg(file.FileName, file.ContentLength); if (code == 501) { return(Success("Picture Format Error")); } else if (code == 502) { return(Success("Size Beyond The Limit")); } QiNiuResultModel resultModel = QiNiuUpLoadApplication.UpLoadBySteam(file.InputStream, file.ContentLength, "PNG"); return(Content(ApiHelper.JsonSerial(resultModel))); }
public ActionResult UpLoadFile() { HttpFileCollectionBase files = HttpContext.Request.Files; if (files == null || files[0] == null) { return(Success("请选择上传文件")); } HttpPostedFileBase file = files[0]; int fixIndex = file.FileName.LastIndexOf("."); string fix = file.FileName.Substring(fixIndex, file.FileName.Length - fixIndex - 1); QiNiuResultModel resultModel = QiNiuUpLoadApplication.UpLoadBySteam(file.InputStream, file.ContentLength, fix); return(Content(ApiHelper.JsonSerial(resultModel))); }