Esempio n. 1
0
        public ActionResult UpLoadFile(bool isWaterMark = true)
        {
            var f = HttpContext.Request.Files[0];

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }
            var fileName = DateTime.Now.ToFileTime() + new Random().Next(100, 999) + Path.GetExtension(f.FileName);

            f.SaveAs(filePath + fileName);

            if (!isWaterMark)
            {
                return(Json(new DataResult <string> {
                    Data = "/Areas/Admin/Content/editor/net/upload/caseimgs/" + fileName
                }));
            }

            var wi      = new Imager();
            var outpath = wi.DrawImage(fileName, AppDomain.CurrentDomain.BaseDirectory + @"Content/image/logo_larger.png", 1,
                                       ImagePosition.Center, filePath);

            return(Json(new DataResult <string> {
                Data = "/Areas/Admin/Content/editor/net/upload/caseimgs/" + outpath
            }));
        }