如何在swal sweetalert中接受多种文件类型

时间:2019-01-29 10:20:35

标签: javascript vue.js yii

我在vue.js应用程序中使用了swal sweet alert。我需要允许多种文件类型。我有允许图像的代码。但是我不知道如何在图像之外允许多种文件类型,例如pdf,ppt和doc。这是我的代码。 非常感谢您的帮助。

swal({
      title: 'Select file',
      input: 'file',
      inputAttributes: {
        'accept': 'image/*',
        'aria-label': 'Upload the file'
     }
})

1 个答案:

答案 0 :(得分:0)

您需要使用逗号,来分隔模因类型,如下所示:

swal({
  title: 'Select file',
  input: 'file',
  inputAttributes: {
    'accept': 'image/*,application/pdf,application/vnd.ms-powerpoint,application/msword',
    'aria-label': 'Upload your profile picture'
  }
})

Codepen:https://codepen.io/anon/pen/pGENrg?&editable=true

您可以在此处找到模因类型的列表:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types