我希望在一个表单中有两个不同的文件上传字段,并使用filepond来很好地管理图像上传。到目前为止,我可以使用filepond,使用文档提供的代码,一个表单中的一个字段没有问题。
我假设我可以在以下更改中放置多个字段:
将输入从filepond_two
的
代码:
<input name="filepond_one[]" id="file_one" type="file" accept="image/jpeg" class="filepond" multiple />
<input name="filepond_two[]" id="file_two" type="file" accept="image/jpeg" class="filepond" multiple />
<script src="js/filepond.min.js"></script>
<script src="js/filepond-plugin-file-validate-size.min.js"></script>
<script src="js/filepond-plugin-image-edit.min.js"></script>
<script src="js/filepond-plugin-image-exif-orientation.min.js"></script>
<script src="js/filepond-plugin-image-preview.min.js"></script>
<script>
FilePond.setOptions({
maxFiles: 4,
maxFileSize: '2MB',
imageResizeTargetWidth: 1200,
labelIdle: 'Drag and Drop up to 4 photos',
labelFileProcessing: 'Uploading',
labelFileProcessingComplete: 'Upload complete',
labelFileProcessingAborted: 'Upload cancelled',
labelFileProcessingError: 'Error during upload',
labelFileProcessingRevertError: 'Error during revert',
labelFileRemoveError: 'Error during remove',
labelTapToCancel: 'tap to cancel',
labelTapToRetry: 'tap to retry',
labelTapToUndo: 'tap to undo',
server: 'photos/filepond/'
});
FilePond.registerPlugin(
FilePondPluginImagePreview,
FilePondPluginImageExifOrientation,
FilePondPluginFileValidateSize,
FilePondPluginImageEdit
);
const inputElements = document.querySelectorAll('input[type="file"]');
Array.from(inputElements).forEach(inputElement => {
FilePond.create(inputElement);
})
</script>更改将filepond样式正确地应用于两个输入,但是更改输入的名称似乎会破坏上传。
发布于 2020-12-10 12:50:22
深入到filepond文件夹,我在config.php文件中看到了这样的内容:
// where to get files from
const ENTRY_FIELD = array('filepond');因此,我添加了字段名,我想使用这样的et“瞧”!
// where to get files from
const ENTRY_FIELD = array('filepond', 'filepond_one', 'filepond_two');希望这对其他人有帮助,因为我被困在这上面一天:-)
https://stackoverflow.com/questions/65234876
复制相似问题