/// <summary> /// 普通上传 /// </summary> /// <param name="context"></param> private void UpLoadFile(HttpContext context) { string delfile = HTRequest.GetString("DelFilePath"); HttpPostedFile upfile = context.Request.Files["Filedata"]; bool iswater = false; //默认不打水印 bool isthumbnail = false; //默认不生成缩略图 if (HTRequest.GetQueryString("IsWater") == "1") { iswater = true; } if (HTRequest.GetQueryString("IsThumbnail") == "1") { isthumbnail = true; } if (upfile == null) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); return; } FileUploader uploader = new FileUploader(); string msg = uploader.FileSaveAs(upfile, isthumbnail, iswater); string webpath = _config["webpath"]; string filepath = _config["filepath"]; if (!string.IsNullOrEmpty(delfile) && delfile.ToLower().StartsWith(webpath.ToLower() + filepath.ToLower())) { Utils.DeleteUpFile(delfile); } //返回成功信息 context.Response.Write(msg); context.Response.End(); }
/// <summary> /// 编辑文件 /// </summary> private void EditorFile(HttpContext context) { bool iswater = false; string water = HTRequest.GetQueryString("IsWater"); if (water == "1") { iswater = true; } HttpPostedFile imgFile = context.Request.Files["imgFile"]; if (imgFile == null) { context.Response.Write(BackInfo(1, "请选择要上传文件!")); return; } FileUploader file = new FileUploader(); string remsg = file.FileSaveAs(imgFile, false, iswater); JObject json = JObject.Parse(remsg); string status = json["status"].ToString(); string msg = json["msg"].ToString(); if (status == "0") { context.Response.Write(BackInfo(1, msg)); return; } string filepath = json["path"].ToString(); context.Response.Write(BackInfo(0, "", filepath)); }