private void EditorFile(HttpContext context) { bool _iswater = false; //默认不打水印 if (context.Request.QueryString["IsWater"] == "1") { _iswater = true; } HttpPostedFile imgFile = context.Request.Files["imgFile"]; if (imgFile == null) { showError(context, "请选择要上传文件!"); return; } UpLoad upFiles = new UpLoad(); string remsg = upFiles.fileSaveAs(imgFile, false, _iswater); Dictionary <string, object> dic = JsonHelper.DataRowFromJSON(remsg); string status = dic["status"].ToString(); string msg = dic["msg"].ToString(); if (status == "0") { showError(context, msg); return; } string filePath = dic["path"].ToString(); //取得上传后的路径 Hashtable hash = new Hashtable(); hash["error"] = 0; hash["url"] = filePath; context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8"); context.Response.Write(JsonHelper.ObjectToJSON(hash)); context.Response.End(); }
private void MergeFiles(HttpContext context) { string guid = context.Request["guid"]; //GUID string filename = context.Request["filename"]; //文件名 string filesize = context.Request["filesize"]; //文件大小 int Ifilesize = 0; string fileExt = Utils.GetFileExt(filename); //文件扩展名,不含“.” int.TryParse(filesize, out Ifilesize); //获得文件大小,以字节为单位 string fileName = filename.Substring(filename.LastIndexOf(@"\") + 1); //取得原文件名 string newFileName = Utils.GetRamCode() + "." + fileExt; //随机生成新的文件名 Web.UI.UpLoad upload = new UpLoad(); string msg = string.Empty; string root = context.Server.MapPath("~/Temp/"); string sourcePath = Path.Combine(root, guid + "/"); //源数据文件夹 string targetPath = Path.Combine(root, Guid.NewGuid() + fileExt); //合并后的文件 DirectoryInfo dicInfo = new DirectoryInfo(sourcePath); if (Directory.Exists(Path.GetDirectoryName(sourcePath))) { msg = upload.MergeFiles(filename, Ifilesize, dicInfo); DeleteFolder(sourcePath); // context.Response.Write("{\"chunked\" : true, \"hasError\" : false, \"savePath\" :\"" + System.Web.HttpUtility.UrlEncode(targetPath) + "\"}"); //context.Response.Write(msg); } //返回成功信息 context.Response.Write(msg); context.Response.End(); }
private void UpLoadFile(HttpContext context) { Rain.Model.siteconfig siteconfig = new Rain.BLL.siteconfig().loadConfig(); string _filepath = DTRequest.GetString("DelFilePath"); HttpPostedFile file = context.Request.Files["Filedata"]; bool isWater = false; bool isThumbnail = false; if (DTRequest.GetQueryString("IsWater") == "1") { isWater = true; } if (DTRequest.GetQueryString("IsThumbnail") == "1") { isThumbnail = true; } if (file == null) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); } else { string s = new UpLoad().fileSaveAs(file, isThumbnail, isWater); if (!string.IsNullOrEmpty(_filepath) && _filepath.IndexOf("../") == -1 && _filepath.ToLower().StartsWith(siteconfig.webpath.ToLower() + siteconfig.filepath.ToLower())) { Utils.DeleteUpFile(_filepath); } context.Response.Write(s); context.Response.End(); } }
//protected void txtPageNum_TextChanged(object sender, EventArgs e) //{ // int _pagesize; // if (int.TryParse(txtPageNum.Text.Trim(), out _pagesize)) // { // if (_pagesize > 0) // { // Utils.WriteCookie("article_page_size", _pagesize.ToString(), 43200); // } // } // Response.Redirect(Utils.CombUrlTxt("order_list.aspx", "", "")); //} //#region 返回图文每页数量========================= //private int GetPageSize(int _default_size) //{ // int _pagesize; // if (int.TryParse(Utils.GetCookie("article_page_size"), out _pagesize)) // { // if (_pagesize > 0) // { // return _pagesize; // } // } // return _default_size; //} //#endregion protected void btnUpdate_Click(object sender, EventArgs e) { HttpPostedFile _upfile = FileUpload1.PostedFile; if (FileUpload1.HasFile == true) { if (FileUpload1.PostedFile.ContentLength > 1073741824) { Response.Write("<script>alert('文件过大,请控制在1G以内!');window.location.href ='" + Utils.CombUrlTxt("category_list_item.aspx", "id={0}", this.id.ToString()) + "'</script>"); Response.End(); } UpLoad upFiles = new UpLoad(); ArrayList array = upFiles.fileSaveAs2(_upfile, null); if (array.Count > 0) { string fileName = array[2].ToString(); string fileSize = array[1].ToString(); string filePath = array[3].ToString(); string fileExt = array[0].ToString(); string username = "******"; string add_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ResultDataSet Rs2 = new ResultDataSet(); database_inte db2 = new database_inte(); string sql2 = "insert into FileInfo (fileName,fileSize,filePath,username,add_time,fileExt,fileType) values ('" + fileName + "','" + fileSize + "','" + filePath + "','" + username + "','" + add_time + "','" + fileExt + "'," + this.id + ")"; if (db2.DB2Obj.GetRs(sql2, out Rs2)) { Response.Redirect(Utils.CombUrlTxt("category_list_item.aspx", "id={0}", this.id.ToString())); } } } else { Response.Write("<script>alert('请选择要上传的文件!');</script>"); } }
public void ProcessRequest(HttpContext context) { //检查是否登录后上传操作 //if (context.Session["AdminNo"] == null) //{ // context.Response.Write("{\"msg\": 0, \"msbox\": \"请登录后再进行上传文件!\"}"); // return; //} HttpPostedFile _upfile = context.Request.Files["FileUpload"]; string _delfile = context.Request.Params["txtImgUrl"]; if (_upfile == null) { context.Response.Write("{\"msg\": 0, \"msbox\": \"请选择要上传文件!\"}"); return; } UpLoad upFiles = new UpLoad(); string msg = upFiles.fileSaveAs(_upfile, 0); //删除已存在的旧文件 if (!string.IsNullOrEmpty(_delfile)) { string _filename = HttpContext.Current.Server.MapPath(_delfile); if (File.Exists(_filename)) { File.Delete(_filename); } } //返回成功信息 context.Response.Write(msg); }
private void MultipleFile(HttpContext context) { string _upfilepath = context.Request.QueryString["UpFilePath"]; //取得上傳的對象名稱 HttpPostedFile _upfile = context.Request.Files[_upfilepath]; bool _iswater = false; //默認不打浮水印 bool _isthumbnail = false; //默認不生成縮略圖 if (context.Request.QueryString["IsWater"] == "1") { _iswater = true; } if (context.Request.QueryString["IsThumbnail"] == "1") { _isthumbnail = true; } if (_upfile == null) { context.Response.Write("{\"msg\": 0, \"msgbox\": \"請選擇要上傳文件!\"}"); return; } UpLoad upFiles = new UpLoad(); string msg = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater, false); //返回成功資訊 context.Response.Write(msg); context.Response.End(); }
private void SingleFile(HttpContext context) { string _refilepath = context.Request.QueryString["ReFilePath"]; //取得返回的对象名称 string _upfilepath = context.Request.QueryString["UpFilePath"]; //取得上传的对象名称 string _delfile = context.Request.Params[_refilepath]; HttpPostedFile _upfile = context.Request.Files[_upfilepath]; bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 if (context.Request.QueryString["IsWater"] == "1") { _iswater = true; } if (context.Request.QueryString["IsThumbnail"] == "1") { _isthumbnail = true; } if (_upfile == null) { context.Response.Write("{msg: 0, msbox: \"请选择要上传文件!\"}"); return; } UpLoad upFiles = new UpLoad(); string msg = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater); //删除已存在的旧文件 Utils.DeleteUpFile(_delfile); //返回成功信息 context.Response.Write(msg); context.Response.End(); }
private void UpLoadFile(HttpContext context) { string _delfile = MXRequest.GetString("DelFilePath"); HttpPostedFile _upfile = context.Request.Files["Filedata"]; bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 if (MXRequest.GetQueryString("IsWater") == "1") { _iswater = true; } if (MXRequest.GetQueryString("IsThumbnail") == "1") { _isthumbnail = true; } if (_upfile == null) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); return; } UpLoad upFiles = new UpLoad(); string msg = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater); //删除已存在的旧文件 if (!string.IsNullOrEmpty(_delfile)) { Utils.DeleteUpFile(_delfile); } //返回成功信息 context.Response.Write(msg); context.Response.End(); }
public async Task <IApiOut> UpLoadFile([ApiVal(Val.File)] IFormFile file, [ApiVal(Val.Service)] UpLoad upFiles, string DelFilePath)//string DelFilePath, string Filedata, string IsWater, string IsThumbnail { AjaxJson _ajv = new(); string _delfile = DelFilePath?.TrimStart('/'); bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 //if (IsWater == "1") // _iswater = true; //if (IsThumbnail == "1") // _isthumbnail = true; if (file == null) { //Json("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); _ajv.code = 1; _ajv.msg = "请选择要上传文件!"; return(await ApiOut.JsonAsync(_ajv)); } //UpLoad upFiles = new(); //删除已存在的旧文件,旧文件不为空且应是上传文件,防止跨目录删除 if (upFiles.FileSaveAs(file, _isthumbnail, _iswater, ref _ajv) && !string.IsNullOrEmpty(_delfile) && _delfile.StartsWith(upFiles.Config.Webpath + upFiles.Config.Filepath, StringComparison.OrdinalIgnoreCase)) { upFiles.DeleteUpFile(_delfile); } //返回成功信息 return(await ApiOut.JsonAsync(_ajv)); }
private void UpLoadFile(HttpContext context) { string _delfile = DTRequest.GetString("DelFilePath"); //要删除的文件 string fileName = DTRequest.GetString("name"); //文件名 byte[] byteData = FileHelper.ConvertStreamToByteBuffer(context.Request.InputStream); //获取文件流 bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 if (DTRequest.GetQueryString("IsWater") == "1") { _iswater = true; } if (DTRequest.GetQueryString("IsThumbnail") == "1") { _isthumbnail = true; } if (byteData.Length == 0) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); return; } UpLoad upLoad = new UpLoad(); string msg = upLoad.FileSaveAs(byteData, fileName, _isthumbnail, _iswater); //删除已存在的旧文件 if (!string.IsNullOrEmpty(_delfile)) { upLoad.DeleteFile(_delfile); } //返回成功信息 context.Response.Write(msg); context.Response.End(); }
private void UpLoadFile(HttpContext context) { string _delfile = GetString("DelFilePath"); HttpPostedFile _upfile = context.Request.Files["Filedata"]; string filepath = GetQueryString("filepath"); string filetypes = GetQueryString("filetypes"); //文件类型 string filetype = GetQueryString("filetype"); //上传类型 3-任务上传 bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 if (GetQueryString("IsWater") == "1") { _iswater = true; } if (GetQueryString("IsThumbnail") == "1") { _isthumbnail = true; } if (_upfile == null) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); return; } UpLoad upFiles = new UpLoad(); string msg = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater, filepath, filetypes, filetype); //返回成功信息 context.Response.Write(msg); context.Response.End(); }
/// <summary> /// 统一保存文件 /// </summary> private void FileSave(HttpContext context, HttpPostedFile upFiles, bool isWater) { if (upFiles == null) { showError(context, "请选择要上传文件!"); return; } //检查是否允许匿名上传 /*if (sysConfig.fileanonymous == 0 && !new ManagePage().IsAdminLogin() && !new BasePage().IsUserLogin()) * { * showError(context, "禁止匿名非法上传!"); * return; * }*/ //获取文件信息 string fileName = upFiles.FileName; byte[] byteData = FileHelper.ConvertStreamToByteBuffer(upFiles.InputStream); //获取文件流 //开始上传 string remsg = new UpLoad().FileSaveAs(byteData, fileName, false, isWater); Dictionary <string, object> dic = JsonHelper.DataRowFromJSON(remsg); string status = dic["status"].ToString(); string msg = dic["msg"].ToString(); if (status == "0") { showError(context, msg); return; } string filePath = dic["path"].ToString(); //取得上传后的路径 showSuccess(context, fileName, filePath); //输出成功提示 }
private void UpLoadFile(HttpContext context) { Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); string _delfile = DTRequest.GetString("DelFilePath"); HttpPostedFile _upfile = context.Request.Files["Filedata"]; bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 if (DTRequest.GetQueryString("IsWater") == "1") { _iswater = true; } if (DTRequest.GetQueryString("IsThumbnail") == "1") { _isthumbnail = true; } if (_upfile == null) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); return; } UpLoad upFiles = new UpLoad(); string msg = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater); //删除已存在的旧文件,旧文件不为空且应是上传文件,防止跨目录删除 if (!string.IsNullOrEmpty(_delfile) && _delfile.IndexOf("../") == -1 && _delfile.ToLower().StartsWith(siteConfig.webpath.ToLower() + siteConfig.filepath.ToLower())) { Utils.DeleteUpFile(_delfile); } //返回成功信息 context.Response.Write(msg); context.Response.End(); }
private void MultipleFile(HttpContext context) { string _upfilepath = context.Request.QueryString["UpFilePath"]; //取得上传的对象名称 HttpPostedFile _upfile = context.Request.Files[_upfilepath]; bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 if (ContextRequest.GetQueryString("IsWater") == "1") { _iswater = true; } if (ContextRequest.GetQueryString("IsThumbnail") == "1") { _isthumbnail = true; } if (_upfile == null) { context.Response.Write("{\"msg\": 0, \"msgbox\": \"请选择要上传文件!\"}"); return; } UpLoad upFiles = new UpLoad(); string msg = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater); //返回成功信息 context.Response.Write(msg); context.Response.End(); }
/// <summary> /// 抓取远程图片 /// </summary> public ActionResult catchimage() { Code.SysConfig.sysconfig sysConfig = new Code.SysConfig.SysConfigApp().loadConfig(); if (sysConfig.fileremote == 0) { return(showError("未开启远程图片本地化")); } string[] sourcesUriArr = Request.Form.GetValues("source[]"); if (sourcesUriArr == null || sourcesUriArr.Length == 0) { return(showError("参数错误:没有指定抓取源")); } UpLoad upLoad = new UpLoad(); //初始化上传类 List <Hashtable> fileList = new List <Hashtable>(); //存储上传成功的文件列表 foreach (string sourcesUri in sourcesUriArr) { string remsg = upLoad.RemoteSaveAs(sourcesUri); Dictionary <string, object> dic = JsonHelper.DataRowFromJSON(remsg); //如果抓取成功则加入文件列表 if (dic["status"].ToString() == "1") { Hashtable hash = new Hashtable(); hash["state"] = "SUCCESS"; hash["source"] = sourcesUri; hash["url"] = dic["path"].ToString(); fileList.Add(hash); } } Dictionary <string, object> result = new Dictionary <string, object>(); result.Add("state", "SUCCESS"); result.Add("list", fileList); return(Content(result.ToJson())); }
public void Delete_UpLoadList(object source, DeleteUpLoadList e) { t_UpLoadSpeed = "上传:0 KB/S"; UpLoad.RemoveAt(e.Id); for (int i = 0; i < UpLoad.Count; i++) { UpLoad[i].MaxSeepd = Limit_Uplaod_Speed; UpLoad[i].sum = UpLoad.Count; } }
private void UpLoadPayFile(HttpContext context) { Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); //检查是否允许匿名上传 if (!new ManagePage().IsAdminLogin()) { context.Response.Write("{\"status\": 0, \"msg\": \"禁止匿名非法上传!\"}"); return; } string fileName = DTRequest.GetString("name"); //文件名 int pid = DTRequest.GetQueryInt("pid"); string ftype = DTRequest.GetQueryString("ftype");; //文件类别 bool _isthumbnail = false; //默认不生成缩略图 byte[] byteData = FileHelper.ConvertStreamToByteBuffer(context.Request.InputStream); //获取文件流 if (byteData.Length == 0) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); return; } if (DTRequest.GetQueryString("IsThumbnail") == "1") { _isthumbnail = true; } UpLoad upLoad = new UpLoad(); fileName = fileName.Replace(" ", "");//去掉空格 string msg = upLoad.PayFileSaveAs(byteData, fileName, _isthumbnail, pid, ftype); msg = Regex.Replace(msg, @"(\\[^bfrnt\\/'\""])", "\\$1");//利用正则表达式先把待解析的字符串中的带“\”特殊字符处理,再进行解析操作 JObject jo = JObject.Parse(msg); if (jo["status"].ToString() == "1") { Model.manager manager = new ManagePage().GetAdminInfo();//获得当前登录管理员信息 Model.payPic file = new Model.payPic(); file.pp_rid = pid; file.pp_type = Utils.ObjToByte(ftype); file.pp_fileName = fileName; file.pp_filePath = jo["path"].ToString(); file.pp_thumbFilePath = jo["thumb"].ToString(); file.pp_size = Utils.ObjToDecimal(jo["size"].ToString(), 0); file.pp_addDate = DateTime.Now; file.pp_addName = manager.real_name; file.pp_addPerson = manager.user_name; new BLL.payPic().insertPayFile(file, manager); } //返回成功信息 context.Response.Write(msg); context.Response.End(); }
public void Close_Socket() { for (int i = 0; i < DownInfo.Count; i++) { DownInfo[i].State = "暂停"; } Serialization(@"./config/ImportDownLoadInfo", DownInfo); Serialization(@"./config/HistoricalRecords", HistoricalRecords); Serialization(@"./config/GarbageInfo", GarbageInfo); Down_d.Clear(); Talk_List.Clear(); UpLoad.Clear(); }
// Token: 0x06000018 RID: 24 RVA: 0x0000336C File Offset: 0x0000156C protected override void View() { if (this.id > 0) { this.desktopinfo = DbHelper.ExecuteModel <DesktopInfo>(this.id); } if (this.desktopinfo.system == 1 && !this.isperm) { this.ShowErr("对不起,您没有权限更改系统图标"); } else { if (this.ispost) { this.desktopinfo = FPRequest.GetModel <DesktopInfo>(); this.desktopinfo.system = (this.isperm ? FPRequest.GetInt("system") : 0); if (this.desktopinfo.id == 0) { this.desktopinfo.uid = this.userid; } if (this.isfile) { HttpPostedFile postedFile = FPRequest.Files["uploadicon"]; UpLoad upLoad = new UpLoad(); string json = upLoad.FileSaveAs(postedFile, "image", this.user, false, false, 32, 32); JsonData jsonData = JsonMapper.ToObject(json); if (jsonData["error"].ToString() == "") { if (this.desktopinfo.icon != "") { if (File.Exists(FPUtils.GetMapPath(this.desktopinfo.icon))) { File.Delete(FPUtils.GetMapPath(this.desktopinfo.icon)); } } this.desktopinfo.icon = jsonData["filename"].ToString(); } } if (this.desktopinfo.id > 0) { DbHelper.ExecuteUpdate <DesktopInfo>(this.desktopinfo); } else { DbHelper.ExecuteInsert <DesktopInfo>(this.desktopinfo); } base.Response.Redirect("desktopmanage.aspx"); } base.SaveRightURL(); } }
public void ProcessRequest(HttpContext context) { //检查是否登录后上传操作 //if (context.Session["AdminNo"] == null) //{ // context.Response.Write("{msg: 0, msbox: \"请登录后再进行上传文件!\"}"); // return; //} string _refilepath = context.Request.QueryString["ReFilePath"]; //取得返回的对象名称 string _upfilepath = context.Request.QueryString["UpFilePath"]; //取得上传的对象名称 int _iswater; //默认打水印 if (!int.TryParse(context.Request.QueryString["IsWater"] as string, out _iswater)) { _iswater = 1; } int _maxFileSize; if (!int.TryParse(context.Request.QueryString["MaxFileSize"] as string, out _maxFileSize)) { _maxFileSize = 1000; } HttpPostedFile _upfile = context.Request.Files[_upfilepath]; string _delfile = context.Request.Params[_refilepath]; if (_upfile == null) { context.Response.Write("{msg: 0, msbox: \"请选择要上传文件!\"}"); return; } if (_upfile.ContentLength > _maxFileSize * 1024) { context.Response.Write("{msg: 0, msbox: \"文件大小超过限制!\"}"); return; } UpLoad upFiles = new UpLoad(); string msg = upFiles.fileSaveAs(_upfile, _iswater); //删除已存在的旧文件 if (!string.IsNullOrEmpty(_delfile)) { string _filename = Utils.GetMapPath(_delfile); if (File.Exists(_filename)) { File.Delete(_filename); } } //返回成功信息 context.Response.Write(msg); }
private void UpLoadOrderFile(HttpContext context) { Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); //检查是否允许匿名上传 if (!new ManagePage().IsAdminLogin()) { context.Response.Write("{\"status\": 0, \"msg\": \"禁止匿名非法上传!\"}"); return; } string fileName = DTRequest.GetString("name"); //文件名 string oID = DTRequest.GetQueryString("oID");; //订单号 string ftype = DTRequest.GetQueryString("ftype");; //文件类别 byte[] byteData = FileHelper.ConvertStreamToByteBuffer(context.Request.InputStream); //获取文件流 if (byteData.Length == 0) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); return; } UpLoad upLoad = new UpLoad(); fileName = fileName.Replace(" ", "");//去掉空格 string msg = upLoad.OrderFileSaveAs(byteData, fileName, oID, ftype); msg = Regex.Replace(msg, @"(\\[^bfrnt\\/'\""])", "\\$1");//利用正则表达式先把待解析的字符串中的带“\”特殊字符处理,再进行解析操作 JObject jo = JObject.Parse(msg); if (jo["status"].ToString() == "1") { Model.manager manager = new ManagePage().GetAdminInfo();//获得当前登录管理员信息 Model.Files file = new Model.Files(); file.f_oid = oID; file.f_type = Utils.ObjToByte(ftype); file.f_fileName = fileName; file.f_filePath = jo["path"].ToString(); file.f_size = Utils.ObjToDecimal(jo["size"].ToString(), 0); file.f_addDate = DateTime.Now; file.f_addName = manager.real_name; file.f_addPerson = manager.user_name; new BLL.Order().insertOrderFile(file, manager); } //返回成功信息 context.Response.Write(msg); context.Response.End(); }
private void DelData(HttpContext context, string btn) { if (btn != "btnDel") { context.Response.Write("{\"status\":\"0.2\",\"msg\":\"对不起,您没有操作权限!\"}"); return; } BLL.System.sys_Attachment bll = new BLL.System.sys_Attachment(); Model.System.sys_LoginUser loginUserModel = BaseWeb.GetLoginInfo(); //string status = "0"; string operaAction = ""; string operaMemo = ""; try { UpLoad upFiles = new UpLoad(); DataTable dt = bll.GetList("Source=1 and UseId=0").Tables[0]; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { upFiles.fileDel(dt.Rows[i]["FilePath"].ToString()); } } bll.Delete("Source=1 and UseId=0"); //status = "1"; operaAction = Enums.ActionEnum.Delete.ToString(); operaMemo = "清理上传文件"; //写入操作日志 BaseWeb.AddOpera(loginUserModel, int.Parse(RequestHelper.GetQueryString("MenuId")), operaAction, operaMemo); context.Response.Write("{\"status\":\"1\",\"msg\":\"清理成功!\"}"); return; } catch (Exception e) { context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}"); return; } }
private void WordExtract(HttpContext context) { string _upfilepath = context.Request.QueryString["UpFilePath"]; //取得上传的对象名称 HttpPostedFile _upfile = context.Request.Files[_upfilepath]; var extension = Path.GetExtension(_upfile.FileName); if (extension != ".docx" && extension != ".doc") { context.Response.Write("{\"msg\": 0, \"msgbox\": \"请您选择word文件上传!\"}"); return; } bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 if (_upfile == null) { context.Response.Write("{\"msg\": 0, \"msgbox\": \"请选择要上传文件!\"}"); return; } UpLoad upFiles = new UpLoad(); string msg = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater, false, false); JsonData msgJson = JsonMapper.ToObject(msg); //word文件上传成功,进行word抽取 if (msgJson["msg"].ToString() == "1") { String wordPath = msgJson["msgbox"].ToString(); String wordContent; try { wordContent = new WordExtrator().GetHtmlFromWord(wordPath, true); } catch (Exception ex) { msgJson["msg"] = "0";//失败 wordContent = "word文档导入失败,可能是word格式不兼容。请您在编辑器中编辑信息!"; } //msgJson["msgbox"] = HttpContext.Current.Server.HtmlEncode(wordContent); //msgJson["msgbox"] = Utils.DropHTML(wordContent); msgJson["msgbox"] = HttpUtility.UrlEncode(wordContent).Replace("+", "%20"); msg = msgJson.ToJson(); } context.Response.Write(msg); context.Response.End(); }
/// <summary> /// 抓取远程图片 /// </summary> private void EditorCatchImage(HttpContext context) { Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); if (sysConfig.fileremote == 0) { Hashtable hash = new Hashtable(); hash["state"] = "未开启远程图片本地化"; context.Response.AddHeader("Content-Type", "text/plain; charset=UTF-8"); context.Response.Write(JsonHelper.ObjectToJSON(hash)); context.Response.End(); } string[] sourcesUriArr = context.Request.Form.GetValues("source[]"); if (sourcesUriArr == null || sourcesUriArr.Length == 0) { Hashtable hash = new Hashtable(); hash["state"] = "参数错误:没有指定抓取源"; context.Response.AddHeader("Content-Type", "text/plain; charset=UTF-8"); context.Response.Write(JsonHelper.ObjectToJSON(hash)); context.Response.End(); } UpLoad upLoad = new UpLoad(); //初始化上传类 List <Hashtable> fileList = new List <Hashtable>(); //存储上传成功的文件列表 foreach (string sourcesUri in sourcesUriArr) { string remsg = upLoad.RemoteSaveAs(sourcesUri); Dictionary <string, object> dic = JsonHelper.DataRowFromJSON(remsg); //如果抓取成功则加入文件列表 if (dic["status"].ToString() == "1") { Hashtable hash = new Hashtable(); hash["state"] = "SUCCESS"; hash["source"] = sourcesUri; hash["url"] = dic["path"].ToString(); fileList.Add(hash); } } Hashtable result = new Hashtable(); result["state"] = "SUCCESS"; result["list"] = fileList; context.Response.AddHeader("Content-Type", "text/plain; charset=UTF-8"); context.Response.Write(JsonHelper.ObjectToJSON(result)); context.Response.End(); }
// Token: 0x060002D8 RID: 728 RVA: 0x0000AE88 File Offset: 0x00009088 private void EditorFile() { HttpPostedFile httpPostedFile = FPRequest.Files["imgfile"]; if (httpPostedFile == null) { this.ShowErrMsg("请选择要上传文件!"); } else { UpLoad upLoad = new UpLoad(); string json = upLoad.FileSaveAs(httpPostedFile, this.dir, this.user); JsonData jsonData = JsonMapper.ToObject(json); string text = jsonData["error"].ToString(); if (text != "") { this.ShowErrMsg(text); } else { AttachInfo attachInfo = new AttachInfo(); attachInfo.uid = this.userid; attachInfo.sortid = this.sortid; attachInfo.filename = jsonData["filename"].ToString(); attachInfo.filesize = (long)FPUtils.StrToInt(jsonData["filesize"].ToString(), 0); attachInfo.originalname = jsonData["originalname"].ToString(); attachInfo.postdatetime = DbUtils.GetDateTime(); attachInfo.filetype = this.dir; if (DbHelper.ExecuteInsert <AttachInfo>(attachInfo) == 0) { this.ShowErrMsg("数据库更新失败。"); } else { Hashtable hashtable = new Hashtable(); hashtable["error"] = 0; hashtable["url"] = attachInfo.filename; hashtable["title"] = attachInfo.originalname; base.Response.AddHeader("Content-Type", "text/html; charset=UTF-8"); base.Response.Write(JsonMapper.ToJson(hashtable)); base.Response.End(); } } } }
private void UpLoadFile(HttpContext context) { string _delfile = RequestHelper.GetString("DelFilePath"); HttpPostedFile _upfile = context.Request.Files["File"]; bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 if (RequestHelper.GetQueryString("IsWater") == "1") { _iswater = true; } if (RequestHelper.GetQueryString("IsThumbnail") == "1") { _isthumbnail = true; } if (_upfile == null) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); return; } string upLoadPath = RequestHelper.GetQueryString("UpLoadPath"); string fileType = ""; if (RequestHelper.GetQueryString("FileType") != null) { fileType = RequestHelper.GetQueryString("FileType"); } UpLoad upFiles = new UpLoad(); string remsg = upFiles.fileSaveAs(_upfile, upLoadPath, _isthumbnail, _iswater, fileType); //删除已存在的旧文件 if (!string.IsNullOrEmpty(_delfile)) { Utils.DeleteUpFile(_delfile); } ResponseInfo(context, remsg); ////返回成功信息 //context.Response.Write(remsg); //context.Response.End(); }
/// <summary> /// 上传涂鸦 /// </summary> public ActionResult uploadscrawl() { byte[] byteData = Convert.FromBase64String(Request["upfile"]); string fileName = "scrawl.png"; //开始上传 string remsg = new UpLoad().FileSaveAs(byteData, fileName, false, false); Dictionary <string, object> dic = JsonHelper.DataRowFromJSON(remsg); string status = dic["status"].ToString(); string msg = dic["msg"].ToString(); if (status == "0") { return(showError(msg)); } string filePath = dic["path"].ToString(); //取得上传后的路径 return(showSuccess(fileName, filePath)); //输出成功提示 }
/// <summary> /// 上传图片的方法 /// 返回缩略图的路劲 /// </summary> /// <param name="context"></param> private string UpLoadFile(HttpContext context) { HttpPostedFile _upfile = context.Request.Files["header_img_id"]; // HttpFileCollection files = HttpContext.Current.Request.Files; bool _iswater = false; //默认不打水印 bool _isthumbnail = true; //默认生成缩略图 _isthumbnail = true; if (_upfile == null) { return(""); } UpLoad upFiles = new UpLoad(); string msg = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater); //返回成功信息 return(msg); }
private void Upload(HttpContext context) { bool iswater = false; //默认不打水印 bool isthumbnail = false; //默认不生成缩略图 int upType = DTRequest.GetInt("type", 0); //上传类型 0图片、1文件、2视频 int width = DTRequest.GetInt("width", siteConfig.thumbnailwidth); int height = DTRequest.GetInt("height", siteConfig.thumbnailheight); HttpPostedFile upFile = context.Request.Files["Filedata"]; if (DTRequest.GetQueryString("IsWater") == "1") { iswater = true; } if (DTRequest.GetQueryString("IsThumbnail") == "1") { isthumbnail = true; } if (null == upFile) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); return; } //开始上传 Model.upLoad model = new UpLoad().fileSaveAs(upFile, upType, isthumbnail, iswater, width, height); if (model.status > 0) { JsonHelper.WriteJson(context, new { status = 1, msg = model.msg, name = model.name, path = model.path, thumb = model.thumb, size = model.size, ext = model.ext }); } else { JsonHelper.WriteJson(context, new { status = 0, msg = model.msg }); } }
private void UpLoadFile(HttpContext context) { Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); //检查是否允许匿名上传 /*if (sysConfig.fileanonymous == 0 && !new ManagePage().IsAdminLogin() && !new BasePage().IsUserLogin()) * { * context.Response.Write("{\"status\": 0, \"msg\": \"禁止匿名非法上传!\"}"); * return; * }*/ string _delfile = DTRequest.GetString("DelFilePath"); //要删除的文件 string fileName = DTRequest.GetString("name"); //文件名 byte[] byteData = FileHelper.ConvertStreamToByteBuffer(context.Request.InputStream); //获取文件流 bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 if (DTRequest.GetQueryString("IsWater") == "1") { _iswater = true; } if (DTRequest.GetQueryString("IsThumbnail") == "1") { _isthumbnail = true; } if (byteData.Length == 0) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); return; } UpLoad upLoad = new UpLoad(); string msg = upLoad.FileSaveAs(byteData, fileName, _isthumbnail, _iswater); //删除已存在的旧文件 if (!string.IsNullOrEmpty(_delfile)) { upLoad.DeleteFile(_delfile); } //返回成功信息 context.Response.Write(msg); context.Response.End(); }
private void user_avatar_crop(HttpContext context) { //检查用户是否登录 Model.users model = new BasePage().GetUserInfo(); if (model == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,用户尚未登录或已超时!\"}"); return; } string fileName = MXRequest.GetFormString("hideFileName"); int x1 = MXRequest.GetFormInt("hideX1"); int y1 = MXRequest.GetFormInt("hideY1"); int w = MXRequest.GetFormInt("hideWidth"); int h = MXRequest.GetFormInt("hideHeight"); //检查是否图片 //检查参数 if (!Utils.FileExists(fileName) || w == 0 || h == 0) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请先上传一张图片!\"}"); return; } //取得保存的新文件名 UpLoad upFiles = new UpLoad(); bool result = upFiles.cropSaveAs(fileName, fileName, 180, 180, w, h, x1, y1); if (!result) { context.Response.Write("{\"status\": 0, \"msg\": \"图片裁剪过程中发生意外错误!\"}"); return; } //删除原用户头像 Utils.DeleteFile(model.avatar); model.avatar = fileName; //修改用户头像 new BLL.users().UpdateField(model.id, "avatar='" + model.avatar + "'"); context.Response.Write("{\"status\": 1, \"msg\": \"" + model.avatar + "\"}"); return; }