简体   繁体   English

重命名使用CKFinder上传的图像

[英]Rename Image Uploaded With CKFinder

我可以重命名使用CKFinder上传的图像吗?

Do you use the PHP version of CKFinder? 您是否使用CKFinder的PHP版本? If so, the following might help. 如果是这样,以下内容可能会有所帮助。

When uploading files, you can automatically remove spaces, characters with accents, and such. 上载文件时,可以自动删除空格,带有重音符号的字符等。 Set "ForceAscii" to "true" in the config.php file: 在config.php文件中将“ ForceAscii”设置为“ true”:

$config['ForceAscii'] = true;

The code for the "ForceAscii" setting is found starting on line 59 in this file: 在此文件的第59行开始找到“ ForceAscii”设置的代码:
ckfinder\\core\\connector\\php\\php5\\CommandHandler\\FileUpload.php ckfinder \\ core \\ connector \\ php \\ php5 \\ CommandHandler \\ FileUpload.php

    if ($_config->forceAscii()) {
      $sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
    }

To rename the file as it's uploaded, you could add your own code to the "ForceAscii" code. 要在上传文件时对其进行重命名,可以将自己的代码添加到“ ForceAscii”代码中。

To add some Static text to the beginning or the end: 要将一些静态文本添加到开头或结尾:

    if ($_config->forceAscii()) {
        $sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
        $sFileName .= "YourTextHere"; // Append your text
        $sFileName = "YourTextHere" . $sFileName; // Prepend your text
    }

Just before the force ascii code is a string replace, you could add your own version of a string replace if that would meet your goals. 在强制ascii代码是字符串替换之前,如果可以满足您的目标,则可以添加自己的字符串替换版本。

$sFileName = str_replace(array(":", "*", "?", "|", "/"), "_", $sUnsafeFileName);

If the text used for the rename will vary, you'll need to provide a lot more details: 如果用于重命名的文本会有所不同,则您需要提供更多详细信息:
Will the text vary depending on which user is uploading the file? 文本会根据上传文件的用户而有所不同吗?
Will it vary for each image, regardless of who uploads it? 不管是谁上传的图片,每个图片都会有所不同吗?
What will determine the actual text that is used (based on username?). 什么将确定使用的实际文本(基于用户名?)。

The latest version, 2.1 allows the user to upload multiple files at one time. 最新版本2.1允许用户一次上传多个文件。 This could affect the approach you take. 这可能会影响您采用的方法。

If you provide additional information, I'll see if I can come up with a better answer. 如果您提供其他信息,我将为您提供更好的答案。


Is this meant to allow the end user to rename their images? 这是否意味着允许最终用户重命名其图像? It is possible for the user to rename an image as follows: 用户可以按以下方式重命名图像:

When they are looking at the images in the file browser window, they would right click on an image. 当他们在文件浏览器窗口中查看图像时,将右键单击图像。 "Rename" is one of the options in the context menu. “重命名”是上下文菜单中的选项之一。

EDIT: The latest version of CKFinder (2.1) has a config setting that is placed in the config.js file: 编辑:最新版本的CKFinder(2.1)具有位于config.js文件中的配置设置:

config.showContextMenuArrow = true;

this setting allows the user to access the context menu by clicking on an arrow that appears in the corner of the image. 此设置允许用户通过单击出现在图像角落的箭头来访问上下文菜单。

Be Well, 好吧
Joe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM