图片或文件上传:
关于图片的上传需要设定2个路径:一个是相对路径;一个是绝对路径。有两种方法,第一种是修改web.config的方法。第二种是直接修改config.ascx 文件( 文件位置:/fckeditor/editor/filemanager/connectors/aspx/目录下)。
1. 修改web.config,添加的内容如下:
<appSettings>
<add key="FCKEditor:BasePath" value="~/fckeditor/"/>
<add key="FCKEditor:UserFilesPath" value="~/uploadfiles/"/>
</appSettings>
一定需要注意的是,路径以"/"结尾,否则会出错。
2. 如果是修改config.ascx,可以打开config.ascx进行修改:
// URL path to user files.
UserFilesPath = "/userfiles/";
// The connector tries to resolve the above UserFilesPath automatically.
// Use the following setting it you prefer to explicitely specify the
// absolute path. Examples: 'C:""MySite""userfiles""' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' URL must point to the same directory.
UserFilesAbsolutePath = "";
同时,FCKEditor针对image/flash/file/media上传类型,会各自添加相应的子目录:
TypeConfig[ "Flash" ].FilesPath = "%UserFilesPath%flash/";
……
TypeConfig[ "Media" ].FilesPath = "%UserFilesPath%media/";
你也可以进一步对上述code进行扩展,如针对不同的用户,自动建立对应的子目录,将用户的文件进行隔离和分开。示例代码如下:
string imagepath = "%UserFilesPath%" + m_userName + "/image/";
TypeConfig["Image"].FilesPath = imagepath;
TypeConfig["Image"].FilesAbsolutePath = (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%image/");
TypeConfig["Image"].QuickUploadPath = imagepath;
TypeConfig["Image"].QuickUploadAbsolutePath = (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%");
最后,还需要修改FCKEditor下面的fckconfig.js 配置文件:
找到:FCKConfig.DefaultLanguage ='en' 改为 FCKConfig.DefaultLanguage ='zh-cn'
找到:var _FileBrowserLanguage = 'php' 改为 var _FileBrowserLanguage = 'aspx'
找到:var _QuickUploadLanguage= 'php' 改为 var _QuickUploadLanguage = 'aspx'
FCKConfig.FontNames = '宋体;黑体;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;