首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Filepond:如何将filepond配置为具有相同格式的多个filepond字段?

Filepond:如何将filepond配置为具有相同格式的多个filepond字段?
EN

Stack Overflow用户
提问于 2020-12-10 12:50:22
回答 1查看 517关注 0票数 1

我希望在一个表单中有两个不同的文件上传字段,并使用filepond来很好地管理图像上传。到目前为止,我可以使用filepond,使用文档提供的代码,一个表单中的一个字段没有问题。

我假设我可以在以下更改中放置多个字段:

将输入从filepond_two

  • adjusting filepond重命名为filepond_one和将document.querySelector('inputtype="file"');重命名为querySelectorAll

代码:

代码语言:javascript
复制
<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样式正确地应用于两个输入,但是更改输入的名称似乎会破坏上传。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-10 12:50:22

深入到filepond文件夹,我在config.php文件中看到了这样的内容:

代码语言:javascript
复制
// where to get files from
const ENTRY_FIELD = array('filepond');

因此,我添加了字段名,我想使用这样的et“瞧”!

代码语言:javascript
复制
// where to get files from
const ENTRY_FIELD = array('filepond', 'filepond_one', 'filepond_two');

希望这对其他人有帮助,因为我被困在这上面一天:-)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65234876

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档