重命名使用 CKFinder 上传的图像

发布于 2024-09-17 18:51:05 字数 32 浏览 3 评论 0原文

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

Can I rename an image that is uploaded using CKFinder?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩饰不了的爱 2024-09-24 18:51:05

您使用 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);

如果用于重命名的文本有所不同,您需要提供更多详细信息:
文本会根据上传文件的用户而有所不同吗?
无论谁上传,每张图片都会有所不同吗?
什么将决定使用的实际文本(基于用户名?)。

最新版本 2.1 允许用户一次上传多个文件。这可能会影响您采取的方法。

如果您提供更多信息,我会看看是否能给出更好的答案。


这是否意味着允许最终用户重命名他们的图像?
用户可以按如下方式重命名图像:

当他们在文件浏览器窗口中查看图像时,他们将右键单击图像。
“重命名”是上下文菜单中的选项之一。

编辑:最新版本的 CKFinder (2.1) 有一个配置设置,位于 config.js 文件中:

config.showContextMenuArrow = true;

此设置允许用户通过单击出现在菜单中的箭头来访问上下文菜单。图像的一角。

祝你好运,

Do you use the PHP version of CKFinder? 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['ForceAscii'] = true;

The code for the "ForceAscii" setting is found starting on line 59 in this file:
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.

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.

$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. 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:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文