public void ProcessRequest(HttpContext context) { context.Response.ContentEncoding = System.Text.Encoding.UTF8; //上传配置 string pathbase = "upload/"; //保存路径 int size = 10; //文件大小限制,单位mb //文件大小限制,单位KB string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" }; //文件允许格式 string callback = context.Request["callback"]; string editorId = context.Request["editorid"]; //上传图片 Hashtable info; var up = new Yreal.Web.UM.Uploader(); info = up.upFile(context, pathbase, filetype, size); //获取上传状态 string json = BuildJson(info); context.Response.ContentType = "text/html"; if (callback != null) { context.Response.Write(String.Format("<script>{0}(JSON.parse(\"{1}\"));</script>", callback, json)); } else { context.Response.Write(json); } }
private void UploadImage() { //上传配置 string pathbase = "upload/"; //保存路径 int size = 10; //文件大小限制,单位mb //文件大小限制,单位KB string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" }; //文件允许格式 //上传图片 Hashtable info; var up = new Yreal.Web.UM.Uploader(); info = up.upFile(this.Context, pathbase, filetype, size); //获取上传状态 Response.ContentType = "text/html"; Response.Redirect("imageUpSuccess.aspx?url=" + info["url"]); }