我可以重命名使用CKFinder上传的图片吗?
如果您使用的是PHP版本的CKFinder,以下内容可能会有所帮助。
在上传文件时,您可以自动删除空格、带重音符号的字符等。在config.php文件中设置"ForceAscii"为"true":
$config['ForceAscii'] = true;
"ForceAscii"设置的代码可以在此文件中的第59行开始找到:
ckfinder\core\connector\php\php5\CommandHandler\FileUpload.php
if ($_config->forceAscii()) {
$sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
}
如果你想在文件上传时将其重命名,你可以在“ForceAscii”代码中添加自己的代码。
如果你想在开头或结尾添加一些静态文本:
if ($_config->forceAscii()) {
$sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
$sFileName .= "YourTextHere"; // Append your text
$sFileName = "YourTextHere" . $sFileName; // Prepend your text
}
在强制 ASCII 代码之前,有一个字符串替换,如果符合您的目标,您可以添加自己的字符串替换版本。
$sFileName = str_replace(array(":", "*", "?", "|", "/"), "_", $sUnsafeFileName);
config.showContextMenuArrow = true;