/// <summary> /// 上传文件 /// </summary> /// <param name="context"></param> /// <returns></returns> public string Upload_post(HttpContext context) { var uploadfor = context.Request["for"]; var id = context.Request["upload.id"]; var dt = DateTime.Now; var dir = string.Format("/images/{0:yyyyMMdd}/", dt); var name = String.Format("{0}{1:HHss}{2}", String.IsNullOrEmpty(uploadfor) ? "" : uploadfor + "_", dt, String.Empty.RandomLetters(4)); var file = new FileUpload(dir, name).Upload(); if (uploadfor == "image") { var rootPath = FwCtx.PhysicalPath; var img = new Bitmap(rootPath + file); int width, height; if (img.Width > img.Height) { width = imgWidth; height = imgHeight; } else { width = imgHeight; height = imgWidth; } var data = GraphicsHelper.DrawBySize(img, ImageSizeMode.CustomSize, width, height, ImageFormat.Png, 100L, 80L, null); img.Dispose(); var ms1 = new MemoryStream(data); img = new Bitmap(ms1); Image water = new Bitmap(waterPath); data = GraphicsHelper.MakeWatermarkImage( img, water, WatermarkPosition.Middle ); ms1.Dispose(); img.Dispose(); var fs = File.OpenWrite(rootPath + file); var w = new BinaryWriter(fs); w.Write(data); w.Flush(); fs.Dispose(); } 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) + "}"; }