/// <summary> /// 清除缓存 /// </summary> public void UploadFile_POST() { string uploadfor = base.Request["for"]; string id = base.Request["upload.id"]; DateTime dt = DateTime.Now; string dir = string.Format("/{0}s{1}/attachment/{2:yyyyMM}/", CmsVariables.RESOURCE_PATH, base.CurrentSite.SiteId.ToString(), dt); string name = String.Format("{0:ddHHss}{1}", dt, String.Empty.RandomLetters(4)); string file = new FileUpload(dir, name).Upload(); Response.Write("{"+String.Format("url:'{0}'",file)+"}"); }
/// <summary> /// 上传文件 /// </summary> /// <param name="context"></param> /// <returns></returns> public string Upload_post(HttpContext context) { string uploadfor = context.Request["for"]; DateTime dt = DateTime.Now; string dir = string.Format(CmsVariables.RESOURCE_PATH+"weixin/{0:yyyyMMdd}/", dt); string name = String.Format("{0}{1:HHss}{2}", String.IsNullOrEmpty(uploadfor) ? "" : uploadfor + "_", dt, String.Empty.RandomLetters(4)); string file = new FileUpload(dir, name).Upload(); return "{" + String.Format("url:'{0}'", file) + "}"; }
/// <summary> /// 上传文件 /// </summary> /// <param name="context"></param> /// <returns></returns> public string Upload_post(HttpContext context) { string uploadfor = context.Request["for"]; DateTime dt = DateTime.Now; string dir = string.Format("{0}{1}/uploads/{2:yyyyMMdd}/", PluginConfig.PLUGIN_DIRECTORY, Config.PluginAttr.WorkIndent , dt); string name = String.Format("{0}{1:HHss}{2}", String.IsNullOrEmpty(uploadfor) ? "" : uploadfor + "_", dt, String.Empty.RandomLetters(4)); string file = new FileUpload(dir, name).Upload(); return "{" + String.Format("url:'{0}'", file) + "}"; }
/// <summary> /// 上传文件 /// </summary> /// <param name="context"></param> /// <returns></returns> public string Upload_post(HttpContext context) { string uploadfor = context.Request["for"]; string id = context.Request["upload.id"]; DateTime dt = DateTime.Now; string dir = string.Format("/images/{0:yyyyMMdd}/", dt); string name = String.Format("{0}{1:HHss}{2}", String.IsNullOrEmpty(uploadfor) ? "" : uploadfor + "_", dt, String.Empty.RandomLetters(4)); string file = new FileUpload(dir, name).Upload(); if (uploadfor == "image") { string rootPath = FwCtx.PhysicalPath; Bitmap img = new Bitmap(rootPath + file); int width, height; if (img.Width > img.Height) { width = imgWidth; height = imgHeight; } else { width = imgHeight; height = imgWidth; } byte[] data = GraphicsHelper.DrawBySize(img, ImageSizeMode.CustomSize, width, height, ImageFormat.Png, 100L, 80L, null); img.Dispose(); MemoryStream ms1 = new MemoryStream(data); img = new Bitmap(ms1); Image water = new Bitmap(waterPath); data = GraphicsHelper.MakeWatermarkImage( img, water, WatermarkPosition.Middle ); ms1.Dispose(); img.Dispose(); FileStream fs = File.OpenWrite(rootPath + file); BinaryWriter w = new BinaryWriter(fs); w.Write(data); w.Flush(); fs.Dispose(); } return "{" + String.Format("url:'{0}'", file) + "}"; }