public string UploadImg() { UploadImage ui = new UploadImage(); ui.SetAllowSize = 1; ui.SetAllowFormat = ".jpeg,.jpg,.bmp,.gif,.png";//配在webConfig中 string url = "/areas/formcontrol/views/_upload/temp/img/"; string saveFolder = Server.MapPath(url); HttpPostedFile file = System.Web.HttpContext.Current.Request.Files[0]; var reponseMessage = ui.FileSaveAs(file, saveFolder); return reponseMessage.ModelToJson(); }
public string UploadImg() { UploadImage ui = new UploadImage(); ui.SetAllowSize = 1; ui.SetAllowFormat = ".jpeg,.jpg,.bmp,.gif,.png";//配在webConfig中 string url = "/areas/formcontrol/views/_upload/temp/img/"; string saveFolder = Server.MapPath(url); HttpPostedFile file = System.Web.HttpContext.Current.Request.Files[0]; var reponseMessage = ui.FileSaveAs(file, saveFolder); return(reponseMessage.ModelToJson()); }
public JsonResult LoadUserPic(string exerciseVguid, string personVguid) { UploadImage ui = new UploadImage(); ui.SetAllowSize = 1000; //允许上传图片的大小(M) ui.SetAllowFormat = ".jpeg,.jpg,.bmp,.gif,.png"; //允许图片上传格式 string url = "/Areas/PersonalCenterManagement/Views/_img/"; //文件保存路径 string saveFolder = Server.MapPath(url); HttpPostedFile file = System.Web.HttpContext.Current.Request.Files[0]; var reponseMessage = ui.FileSaveAs(file, saveFolder);//保存图片 //System.Threading.Thread.Sleep(10000); if (!reponseMessage.IsError) { url = System.IO.Path.Combine(url, reponseMessage.FileName); bool imgResult = _wl.UpLoadImg(url, exerciseVguid, personVguid); } return(Json(reponseMessage)); }
protected void Button1_Click(object sender, EventArgs e) { UploadImage ui = new UploadImage(); /***可选参数***/ ui.SetWordWater = "哈哈"; //文字水印 // ui.SetPicWater = Server.MapPath("2.png");//图片水印(图片和文字都赋值图片有效) ui.SetPositionWater = 4; //水印图片的位置 0居中、1左上角、2右上角、3左下角、4右下角 ui.SetSmallImgHeight = "110,40,20"; //设置缩略图可以多个 ui.SetSmallImgWidth = "100,40,20"; //保存图片生成缩略图 var reponseMessage = ui.FileSaveAs(Request.Files[0], Server.MapPath("~/Form/temp")); //裁剪图片 var reponseMessage2 = ui.FileCutSaveAs(Request.Files[0], Server.MapPath("~/Form/temp2"), 400, 300, UploadImage.CutMode.CutNo); /***返回信息***/ var isError = reponseMessage.IsError; //是否异常 var webPath = reponseMessage.WebPath; //web路径 var filePath = reponseMessage.filePath; //物理路径 var message = reponseMessage.Message; //错误信息 var directory = reponseMessage.Directory; //目录 var smallPath1 = reponseMessage.SmallPath(0); //缩略图路径1 var smallPath2 = reponseMessage.SmallPath(1); //缩略图路径2 var smallPath3 = reponseMessage.SmallPath(2); //缩略图路径3 /*test*/ Image1.ImageUrl = reponseMessage.WebPath; Image2.ImageUrl = reponseMessage2.WebPath; }
public JsonResult UploadImg(string id) { UploadImage ui = new UploadImage(); ui.SetAllowSize = 1000; //允许上传图片的大小(M) ui.SetAllowFormat = ".jpeg,.jpg,.bmp,.gif,.png"; //允许图片上传格式 string url = "/Areas/WeChatPush/Views/_img/"; //文件保存路径 string saveFolder = Server.MapPath(url); //HttpPostedFile file = System.Web.HttpContext.Current.Request.Files[0]; string fileName = "CoverImgs"; if (id != "0") { fileName = "CoverImgs" + id; } HttpPostedFile file = System.Web.HttpContext.Current.Request.Files[fileName]; var reponseMessage = ui.FileSaveAs(file, saveFolder); //保存图片 if (!reponseMessage.IsError) { Path.Combine(url, reponseMessage.FileName); } return(Json(reponseMessage, "text/html")); }