FilePond:所有 JPEG 文件均以“.jpg”形式上传- 为什么?

发布于 2025-01-20 13:58:09 字数 183 浏览 2 评论 0原文

我写了一个小的filepond示例(出色的工作btw),但是有一件事我无法理解:

当我上传时,例如,“ foo.jpg”或“ foo.jpeg”,它被保存为“ foo .jpg“在服务器上。

我想保留文件扩展名,但不知道该怎么做。

我已经尝试了filerename-plugin,但这些文件仍然保存为.jpg。

I've written a small FilePond example (excellent piece of work BTW) but there is one thing that I can't understand:

When I upload, e.g., "foo.JPG" or "foo.jpeg" it is saved as "foo.jpg" on the server.

I would like to keep the file extension, but don't know how to do it.

I've tried the FileRename-plugin but the files are still saved as .jpg.

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

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

发布评论

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

评论(1

时光瘦了 2025-01-27 13:58:10

我想出了一个解决方案。如果有人感兴趣,我可以发布完整的代码,但基本上我将真实的文件名(例如“foo.jpeg”)存储在元数据中,并在 PHP 服务器端提取它,然后使用该名称重命名临时文件。

在 FilePond.create 中:

beforeAddFile: (fileItem) => new Promise(resolve => {
    fileItem.setMetadata('true_filename', fileItem.filename);
    resolve(true);
}),

I worked out a solution. If anyone is interested I can post complete code, but basically I stored the real filename (e.g., "foo.jpeg") in metadata and extracted it on the PHP server side, and then renamed the temporary file using that name instead.

In FilePond.create:

beforeAddFile: (fileItem) => new Promise(resolve => {
    fileItem.setMetadata('true_filename', fileItem.filename);
    resolve(true);
}),
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文