FCKeditor中添加删除图片的功能!
2009-11-10 15:28
519 查看
1、在/fckeditor/editor/filemanager/browser/default文件夹中找到frmresourceslist.html文件,将其代码改为:
2、在该文件的js中增加如下代码(js/common.js):
3、在同一个目录(指frmresourceslist.html所在目录)增加一个文件:FCKdel_file.aspx,代码如下:
oListManager.GetFileRowHtml = function(fileName, fileUrl, fileSize) { // Build the link to view the folder. var sLink = '<a href="#" mce_href="#" onclick="OpenFile(/'' + ProtectPath(fileUrl) + '/');return false;">'; // Get the file icon. var sIcon = oIcons.GetIcon(fileName); return '<tr>' + '<td width="16">' + sLink + '<img alt="" src="images/icons/' + sIcon + '.gif" mce_src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"> <//a>' + '<//td><td> ' + sLink + fileName + '<//a> <a href="#" mce_href="#" onclick="deleteFile(/'' + ProtectPath(fileUrl) + '/');" style="color: #FF9933;" mce_style="color: #FF9933;"> 删除 <//a>' + '<//td><td align="right" nowrap> ' + fileSize + ' KB' + '<//td><//tr>'; }
2、在该文件的js中增加如下代码(js/common.js):
//******************************** 图片删除功能 ****************************************** var req; //定义变量,用来创建xmlhttprequest对象 //产生不重复的随机数 var rn = Math.ceil(Math.random() * 1000000); var rnch = rn; function rndnum() { while (rn == rnch) rn = Math.ceil(Math.random() * 1000000); rnch = rn; return rn; } // 删除文件,Ajax开始 function deleteFile(file) { var url = "FCKdel_file.aspx?filePath=" + escape(file) + "&UD=" + rndnum(); //要请求的服务端地址 if (window.XMLHttpRequest) //非IE浏览器及IE7(7.0及以上版本),用xmlhttprequest对象创建 { req = new XMLHttpRequest(); } else if (window.ActiveXObject) //IE(6.0及以下版本)浏览器用activexobject对象创建,如果用户浏览器禁用了ActiveX,可能会失败. { req = new ActiveXObject("Microsoft.XMLHttp"); } if (req) //成功创建xmlhttprequest { req.open("GET", url, true); //与服务端建立连接(请求方式post或get,地址,true表示异步) req.onreadystatechange = callback; //指定回调函数 req.send(null); //发送请求 } } function callback() { Refresh(); //刷新一下 }
3、在同一个目录(指frmresourceslist.html所在目录)增加一个文件:FCKdel_file.aspx,代码如下:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string UD = Shove._Web.Utility.GetRequest("UD"); //生成的随机数 string FilePath = Shove._Web.Utility.GetRequest("filePath"); DeleteFile(FilePath); } } private void DeleteFile(string FileName) { string Result = "-2"; if (string.IsNullOrEmpty(FileName)) { Result = "0"; // 文件删除失败!请检查文件是否存在! } try { //string Root = System.AppDomain.CurrentDomain.BaseDirectory; //当前应用程序目录 //FileName = FileName.Replace("/SFS_BQW/", ""); //System.IO.File.Delete(Root + FileName); System.IO.File.Delete(Server.MapPath(FileName)); } catch { Result = "-2"; // 未知错误! } Result = "1"; Response.Write(Result); }
相关文章推荐
- fckeditor添加删除图片功能
- FckEditor添加右键菜单;增加编辑区右键图片删除功能(asp.net )
- FCKeditor中添加删除图片的功能!
- FckEditor添加右键菜单;增加编辑区右键图片删除功能(asp.net )(一)
- FckEditor添加右键菜单;增加编辑区右键图片删除功能(asp.net )(二)
- 如何为fckeditor文本编辑器增加图片删除功能
- FCKeditor删除文件图片功能
- Asp.net为FCK添加图片删除功能
- 一个iOS图片选择器的DEMO(实现图片添加,宫格排列,图片长按删除,以及图片替换等功能)
- FCKeditor编辑器添加图片上传功能及图片路径问题解决方法
- UEditor 添加在线管理图片删除功能
- springMvc+webUploader图片从后台取出,回显后,添加图片删除功能
- 为 FCKeditor增加图片预览和删除文件、删除文件夹功能(c#)
- Android GridView扩展仿微信微博发图动态添加删除图片功能
- fckeditor给文件(包括图片)及文件夹增加删除功能
- FCKEditor增加带确认的“删除”功能和图片预览功能
- 一个iOS图片选择器的DEMO(实现图片添加,宫格排列,图片长按删除,以及图片替换等功能)
- ajax php实现给fckeditor文本编辑器增加图片删除功能
- FCKeditor添加删除功能
- FCKEditor 2.63 上传图片时,可按日期生成文件名、生成缩略图、添加水印