FCKeditor 上传图片自动重命名
2008-04-15 11:50
323 查看
FCKeditor 的文件上传默认是不改名的,本地的文件名是什么,上传后保留原来的文件名;如果存在同名文件,则会被自动在文件名后面加 (n) 来标识。
FCKeditor For ASP.NET 的上传部分被编译到 DLL 文件里面了,所以只能通过修改源代码,再重新编译后方能使用。
使用:FCKeditor.Net_2.5.zip,asp.net 2.0版
找到项目中的FileBrowser/FileWorkerBase.cs
while (true)
...{
string sFilePath = System.IO.Path.Combine(sServerDir, sFileName);
if (System.IO.File.Exists(sFilePath))
...{
iCounter++;
sFileName = System.IO.Path.GetFileNameWithoutExtension(oFile.FileName) + "(" + iCounter + ")." + sExtension;
iErrorNumber = 201;
}
else
...{
oFile.SaveAs(sFilePath);
break;
}
}
修改后的代码变成:
while (true)
...{
sFileName = DateTime.Now.ToString("yyyymmddhhmmss", System.Globalization.DateTimeFormatInfo.InvariantInfo) + "." + sExtension;//以时间命名文件
string sFilePath = System.IO.Path.Combine(sServerDir, sFileName);
oFile.SaveAs(sFilePath);
break;
}
重新生成解决方案。在网站项目中删除旧的FredCK.FCKeditorV2.dll,再添加新的引用,就OK了。
FCKeditor For ASP.NET 的上传部分被编译到 DLL 文件里面了,所以只能通过修改源代码,再重新编译后方能使用。
使用:FCKeditor.Net_2.5.zip,asp.net 2.0版
找到项目中的FileBrowser/FileWorkerBase.cs
while (true)
...{
string sFilePath = System.IO.Path.Combine(sServerDir, sFileName);
if (System.IO.File.Exists(sFilePath))
...{
iCounter++;
sFileName = System.IO.Path.GetFileNameWithoutExtension(oFile.FileName) + "(" + iCounter + ")." + sExtension;
iErrorNumber = 201;
}
else
...{
oFile.SaveAs(sFilePath);
break;
}
}
修改后的代码变成:
while (true)
...{
sFileName = DateTime.Now.ToString("yyyymmddhhmmss", System.Globalization.DateTimeFormatInfo.InvariantInfo) + "." + sExtension;//以时间命名文件
string sFilePath = System.IO.Path.Combine(sServerDir, sFileName);
oFile.SaveAs(sFilePath);
break;
}
重新生成解决方案。在网站项目中删除旧的FredCK.FCKeditorV2.dll,再添加新的引用,就OK了。
相关文章推荐
- FCKeditor 上传图片自动重命名
- 支持代码高亮、图片水印、远程文件自动上传的fckeditor
- FCKEditor上传图片后,如何进行重命名
- FCKeditor V2.x上传文件自动重命名
- fckeditor 2.5 上传图片会自动改名
- WordPress 中文图片 上传 自动重命名
- FCKEditor上传图片重命名
- WordPress 中文图片 上传 自动重命名
- 如何让wordpress上传图片的时候自动命名?
- fckeditor 2.5 上传图片会自动改名
- ASP实现上传图片自动 压缩图片大小 留存待修改
- ASP.NET 使用FileUpload控件上传图片并自动生成缩略图
- ASP.NET环境下配置FCKEditor并上传图片及其它文件
- 上传图片、预览、按上传时间命名保存
- 单独使用FCKeditor的图片上传功能
- kindeditor上传图片自动压缩过大的图片
- ASP.NET修改FCKeditor中asp.net上传文件时的命名
- 使用FCKeditor_2.6.3版本有关上传图片问题解决
- ASP.NET环境下配置FCKEditor并上传图片及其它文件