首页 > 解决方案 > 如何使用 sweetalert2 上传多个文件

问题描述

我想上传多个文件,这段代码只选择一个文件上传

const { value: file } = await Swal.fire({
  title: 'Select image',
  input: 'file',
  inputAttributes: {
    'accept': 'image/*',
    'aria-label': 'Upload your profile picture'
  }
})

代码笔链接

标签: javascriptjquerysweetalertsweetalert2

解决方案


您需要添加multiple到您的输入

const { value: file } = await Swal.fire({
  title: 'Select image',
  input: 'file',
  inputAttributes: {
    'accept': 'image/*',
    'multiple': 'multiple', 
    'aria-label': 'Upload your profile picture'
  }
})

推荐阅读