0

I am using Filepond, an otherwise amazing plugin, but when I try to place multiple instances on the same page, only the last instance uploads correctly. All the other ones display correctly, but only upload to the "tmp" folder: the files never making it to the "uploads" folder.

The code I'm using is the following, that was actually found in a previous SO question (the only difference is my "define server location" at the end): How do I set up multiple FilePond file input elements on the same page?

Here it is:

<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>

Thank you dearly!

Ben Viatte
  • 485
  • 1
  • 5
  • 16

1 Answers1

2

Sorry that this answer is coming late. Just do it like this below

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/',
});
});
Manomite
  • 36
  • 3
  • Thank you so much! Until now, unable to find a solution I had solely been working with the tmp folder, as a workaround... – Ben Viatte Aug 17 '21 at 16:49