[原创]让FCKeditor的File manager支持”删除” (php)
FCKeditor是一款很好用的所见即所得编辑器, 内置的File manager也实现了基本的文件管理功能, 唯一遗憾的是, 不支持删除…
没关系, 其实只需以下几步就可以实现删除文件和文件夹:
1, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, 编辑:
oListManager.GetFolderRowHtml = function( folderName, folderPath, folderUrl ) { // Build the link to view the folder. var sLink = '' ; return '' + ' ' + sLink + '' + ' ' + sLink + folderName + '' + ' - Delete ' ; }
2, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, 编辑:PHP code
oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize ) { // Build the link to view the folder. var sLink = '' ; // Get the file icon. var sIcon = oIcons.GetIcon( fileName ) ; return '' + ' ' + sLink + '' + ' ' + sLink + fileName + '' + ' ' + fileSize + ' KB' + ' - Delete ' ; }
3, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, 增加:PHP code
function DeleteFile( fileName, fileUrl ) { if (confirm('Are you sure you wish to delete ' + fileName + '?')) { oConnector.SendCommand( 'DeleteFile', "FileUrl=" + escape( fileUrl ), Refresh ) ; } } function DeleteFolder( folderName, folderPath ) { if (confirm('Are you sure you wish to delete \'' + folderName + '\' and all files in it?')) { oConnector.SendCommand( 'DeleteFolder', "FolderName=" + escape( folderPath + folderName ), Refresh ) ; } }Copy after login
4, fckeditor\editor\filemanager\browser\default\frmresourceslist.html, 编辑:
PHP code
oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/", sCurrentFolderUrl ) ) ;Copy after login
5, fckeditor\editor\filemanager\connectors\php\commands.php, 添加:
PHP code
function DeleteFile( $resourceType, $currentFolder ) { $file = $_SERVER['DOCUMENT_ROOT'].$_GET['FileUrl']; if (is_file($file)) { unlink($file); } else { echo ''; } } function DeleteFolder( $resourceType, $currentFolder ) { $folder = $_SERVER['DOCUMENT_ROOT'].$_GET['FolderName']; if (is_dir($folder) ) { DELETE_RECURSIVE_DIRS($folder); } else { echo ' '; } } function DELETE_RECURSIVE_DIRS($dirname) { // recursive function to delete // all subdirectories and contents: if(is_dir($dirname))$dir_handle=opendir($dirname); while($file=readdir($dir_handle)) { if($file!="." && $file!="..") { if(!is_dir($dirname."/".$file)) { unlink ($dirname."/".$file); } else { DELETE_RECURSIVE_DIRS($dirname."/".$file); } } } closedir($dir_handle); rmdir($dirname); } Copy after loginPrevious article: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result res,该怎么解决 Next article: 二维数组中如何除去重复项呢Statement of this WebsiteThe content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cnLatest Articles by Author
2024-08-17 00:45:11 2024-08-17 00:44:11 2024-08-17 00:41:11 2024-08-17 00:38:11 2024-08-17 00:37:10 2024-08-17 00:32:10 2024-08-17 00:30:10 2024-08-17 00:29:10 2024-08-17 00:27:10 2024-08-17 00:24:10Latest IssuesRelated TopicsMore>Popular RecommendationsPopular TutorialsMore>
JAVA Beginner's Video Tutorial2347778 Latest DownloadsMore>
- About us Disclaimer Sitemap
- php.cn:Public welfare online PHP training,Help PHP learners grow quickly!