【问题标题】:Filepond with multiple instances on one page: only the last instance uploads correctly一个页面上有多个实例的文件池:只有最后一个实例正确上传
【发布时间】:2020-09-08 14:09:46
【问题描述】:

我正在使用 Filepond,这是一个非常棒的插件,但是当我尝试在同一页面上放置多个实例时,只有最后一个实例可以正确上传。所有其他文件都正确显示,但只上传到“tmp”文件夹:文件永远不会进入“uploads”文件夹。

我使用的代码如下,实际上是在之前的 SO 问题中找到的(唯一的区别是我最后的“定义服务器位置”): How do I set up multiple FilePond file input elements on the same page?

这里是:

<input type="file" class="filepond">
<input type="file" class="filepond">
<input type="file" class="filepond">

<script>
// get a collection of elements with class filepond
const inputElements = document.querySelectorAll('input.filepond');

// loop over input elements
Array.from(inputElements).forEach(inputElement => {

// create a FilePond instance at the input element location
FilePond.create(inputElement);

// define the server location
FilePond.setOptions({
server: 'http://localhost:8080/wp12-fidusalaire/wp-content/plugins/one-shot-form/',
});


})
</script>

非常感谢!

【问题讨论】:

    标签: javascript upload filepond


    【解决方案1】:

    抱歉,这个答案来晚了。像下面这样操作就行了

    const inputElements = document.querySelectorAll('input.filepond');
    
    // loop over input elements
    Array.from(inputElements).forEach(inputElement => {
    
    const pond = FilePond.create(inputElement, options);
    
    // define the server location
    pond.setOptions({
    server: 'http://localhost:8080/wp12-fidusalaire/wp-content/plugins/one-shot-form/',
    });
    });

    【讨论】:

    • 非常感谢!直到现在,作为一种解决方法,我一直无法找到我一直使用 tmp 文件夹的解决方案......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-18
    • 2012-05-04
    • 1970-01-01
    • 2019-09-27
    • 2021-02-06
    • 2016-06-11
    • 1970-01-01
    相关资源
    最近更新 更多