fckeditor文件上传后显示文件类型图标、短文件名、文件字节

以下所谓的行数可能和你的不同,版本2.6.4

1、editor\dialog\fck_link.htm
大约58行,找到<input id="txtUrl" style="WIDTH: 100%" type="text" onkeyup="OnUrlChange();" onchange="OnUrlChange();" />
在下面添加
<input id="txtSize" type="hidden" value="0" />

2、editor\dialog\fck_link\fck_link.js

a:大约826行
function SetUrl( url, sdiv )
{
GetE('txtUrl').value = url ;
OnUrlChange() ;
dialog.SetSelectedTab( 'Info' ) ;
}
修改为
function SetUrl( url, size, sdiv )
{
GetE('txtUrl').value = url ;
GetE('txtSize').value = size ;
OnUrlChange() ;
dialog.SetSelectedTab( 'Info' ) ;
}

b:大约637行
function Ok()下,在var sUri, sInnerHtml后增加", sSize",即var sUri, sInnerHtml, sSize ;
再往下找到
case 'url':
sUri = GetE('txtUrl').value ;
在下面添加
sSize= GetE('txtSize').value;
//如不想显示字节则屏蔽下一行
sSize= "&nbsp;&nbsp;[" + sSize + " byte]";

c:再往下大约734行,找到
if ( aHasSelection )
sInnerHtml = oLink.innerHTML ;
在下面添加如下几行
var aUrl = sInnerHtml.split("/");
var lUrl = aUrl.length;
var sName= aUrl[lUrl-1]; //取文件名.后缀名
//如果不想显示文件类型图标则屏蔽下面四行
var aExt = sInnerHtml.split(".");
var lExt = aExt.length;
var uImg = aExt[lExt-1] + ".gif" //取文件类型图标
var img  = "<img src='/Images/FileType/" + uImg + "' alt='' style='width:18px;height:18px;border:0;' />";
//如果不想显示文件类型图标则定义一个空的img
sInnerHtml = img + "&nbsp;&nbsp;" + sName + sSize;

3、editor\filemanager\connectors\asp\commands.asp

找到Sub FileUpload( resourceType, currentFolder, sCommand )
a:在该过程中找到
Dim sFileName, sOriginalFileName, sExtension
在后面添加, sFileSize

b:在该过程中继续找到
Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
if not (oFSO.FolderExists( sServerDir ) ) then
sErrorNumber = "102"
else
' Get the uploaded file name.
sFileName    = oUploader.File( "NewFile" ).Name
sExtension    = oUploader.File( "NewFile" ).Ext
在下面添加
sFileSize   = oUploader.File( "NewFile" ).Size

c:在该过程中继续找到
sFileUrl = CombinePaths( sFileUrl, sFileName )
在下面添加
'显示上载结果
SendUploadResults sErrorNumber, sFileUrl, sFileName, "", sFileSize

4、editor\filemanager\connectors\asp\io.asp

' This is the function that sends the results of the uploading process.
Sub SendUploadResults( errorNumber, fileUrl, fileName, customMsg )
Response.Clear
Response.Write "<script type=""text/javascript"">"
' Minified version of the document.domain automatic fix script (#1919).
' The original script can be found at _dev/domain_fix_template.js
Response.Write "(function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})();"

Response.Write "window.parent.OnUploadCompleted(" & errorNumber & ",""" & Replace( fileUrl, """", "\""" ) & """,""" & Replace( fileName, """", "\""" ) & """,""" & Replace( customMsg , """", "\""" ) & """) ;"
Response.Write "</script>"
Response.End
End Sub
替换为
' This is the function that sends the results of the uploading process.
'显示上载结果
Sub SendUploadResults( errorNumber, fileUrl, fileName, customMsg, fileSize )
Response.Clear
Response.Write "<script type=""text/javascript"">"
' Minified version of the document.domain automatic fix script (#1919).
' The original script can be found at _dev/domain_fix_template.js
Response.Write "(function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})();"

Response.Write "window.parent.OnUploadCompleted(" & errorNumber & ",""" & Replace( fileUrl, """", "\""" ) & """,""" & Replace( fileName, """", "\""" ) & """,""" & Replace( customMsg , """", "\""" ) & """, " & fileSize & ") ;"
Response.Write "</script>"
Response.End
End Sub

以上修改完毕保存,上传文件后就会显示文件类型图标、短文件名、文件字节,遗憾的是全链接,不是只短文件名链接。

 

你可能感兴趣的:(JavaScript,c,ext,fckeditor,asp)