选择Android web上输入类型为file:excel文件的文件,并返回PDF mime类型
我想将我的移动web应用程序上的文件上载限制为图像和PDF文件类型。但是,当我在Android上的Chrome中打开文件选择器时,我可以选择excel文件,根据我在中指定的内容,这些文件不应该可以选择。这个问题似乎是安卓系统特有的——excel文件在iOS系统中呈灰色,隐藏在桌面上 此外,如果我通过文件选择器导航到Google Drive并选择一个excel文件,则返回的文件mime类型为选择Android web上输入类型为file:excel文件的文件,并返回PDF mime类型,excel,google-drive-api,mime-types,input-type-file,Excel,Google Drive Api,Mime Types,Input Type File,我想将我的移动web应用程序上的文件上载限制为图像和PDF文件类型。但是,当我在Android上的Chrome中打开文件选择器时,我可以选择excel文件,根据我在中指定的内容,这些文件不应该可以选择。这个问题似乎是安卓系统特有的——excel文件在iOS系统中呈灰色,隐藏在桌面上 此外,如果我通过文件选择器导航到Google Drive并选择一个excel文件,则返回的文件mime类型为application/pdf。在这里,我希望将application/vnd.openxmlformats
application/pdf
。在这里,我希望将application/vnd.openxmlformats officedocument.spreadsheetml.sheet
或application/vnd.google apps.spreadsheet
作为mime类型。这仅适用于来自Google Drive的excel文件,即从下载中选择excel文件将返回预期的mime类型
因此,我有两个问题:
1。Android是否会遵循accept属性中指定的文件类型?
2。为什么从Google Drive中选择的excel文件返回PDF mime类型? 接受图像和PDF文件的输入元素:
<input onchange="showImage('Files')" type="file" name="Files" accept="image/*,.pdf" value="Upload a file"">
以及所选文件的日志:
File(47847){name:“gratefusions.pdf”,lastModified:1536163728724,lastModifiedDate:Wed Sep 05 2018 11:08:49 GMT-0500(hora de verano central),webkitRelativePath:,大小:47847,…}
最后修改:1536163745655
最后修改日期:2018年9月5日星期三11:09:06 GMT-0500(维拉诺中心)
名称:“感激之情.pdf”
尺码:47847
类型:“应用程序/pdf”
webkitRelativePath:“
__原型:文件
function showImage(type){
var file = document.querySelector(`input[name=${type}]`).files[0];
console.log(file);
}