示例#1
0
        public JsonResult Upload()
        {
            try
            {
                var fileBase = Request.Form.Files["File"];

                //if (fileBase == null || fileBase.FileName == "")
                //{
                //    return Json(new { success = false, url = "请选择要上传的图片!" });
                //}
                //if (fileBase.Length >= 1024 * 1000)
                //{
                //    return Json(new { success = false, url = "图片大小不能超过1M!" });
                //}
                //string ext = fileBase.FileName.Substring(fileBase.FileName.LastIndexOf('.'));
                //if (ext.ToLower() != ".jpg" && ext.ToLower() != ".jpeg" && ext.ToLower() != ".gif" && ext.ToLower() != ".png" && ext.ToLower() != ".bmp")
                //{
                //    return Json(new { success = false, url = "图片文件格式不正确!" });
                //}
                return(_AppService.SaveSingleImg(fileBase, _AbpSession.TenantId != null ? (int)_AbpSession.TenantId : 0));
            }
            catch (Exception e)
            {
                Logger.Warn("----------------------------------");
                throw new Exception(e.StackTrace + e.Message);
            }
        }