Я использую Filepond, в остальном замечательный плагин, но когда я пытаюсь разместить несколько экземпляров на одной странице, правильно загружается только последний экземпляр. Все остальные отображаются правильно, но загружаются только в папку «tmp»: файлы никогда не попадают в папку «uploads».
Я использую следующий код, который был фактически найден в предыдущем вопросе SO (единственное отличие состоит в моем «определении местоположения сервера» в конце):
как настроить несколько элементов ввода файлов FilePond на одной странице?
Вот:
<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>
Большое спасибо!
Решение проблемы
Извините, что этот ответ приходит поздно. Просто сделайте это так, как показано ниже
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/',
});
});
Комментариев нет:
Отправить комментарий