美文网首页大前端前端开发那些事儿
上传文件使用accept,提示:没有应用可执行此操作

上传文件使用accept,提示:没有应用可执行此操作

作者: 冷r | 来源:发表于2022-04-21 17:14 被阅读0次

一、前言

在微信里使用input的file属性选择图片文件,提示没有应用可执行此操作,在浏览器中是正常的,经过测试发现是“accept”属性的问题


问题示例

二、正片

1、这个写法在pc端是可以识别的,可以调起选择器,但在移动端是无法识别的

<input type="file" accept=".jpg,.png,.gif"/>

2、移动端需要换成下面的写法

<input type="file" accept="image/jpeg,image/png,image/gif"/>

三、结尾加餐

  • 注:如果不限制图像的格式,可以写为:accept="image/*"。

附上accept属性列表:

1.accept="application/msexcel"
2.accept="application/msword"
3.accept="application/pdf"
4.accept="application/poscript"
5.accept="application/rtf"
6.accept="application/x-zip-compressed"
7.accept="audio/basic"
8.accept="audio/x-aiff"
9.accept="audio/x-mpeg"
10.accept="audio/x-pn/realaudio"
11.accept="audio/x-waw"
12.accept="image/gif"
13.accept="image/jpeg"
14.accept="image/tiff"
15.accept="image/x-ms-bmp"
16.accept="image/x-photo-cd"
17.accept="image/x-png"
18.accept="image/x-portablebitmap"
19.accept="image/x-portable-greymap"
20.accept="image/x-portable-pixmap"
21.accept="image/x-rgb"
22.accept="text/html"
23.accept="text/plain"
24.accept="video/quicktime"
25.accept="video/x-mpeg2"
26.accept="video/x-msvideo"

相关文章

网友评论

    本文标题:上传文件使用accept,提示:没有应用可执行此操作

    本文链接:https://www.haomeiwen.com/subject/afxwertx.html