随身笔记
随身笔记

移动端使用input type=file时没有type类型判断

js 手机 移动 移动端 input type file type 空

<input id="img1" type="file" name="file" accept="audio/mpeg"  />

$('#img1')[0].files[0] //获取到如下图片
https://sdeno.com/wp-content/uploads/2019/08/xx20190808184544.jpg

在pc端能获取到type类型,但是到了移动端就不能获取了

type为空。

 

1,解决办法

(1)手机端判断type为空绕过不进行校验,设置input    accept=”audio/mpeg”

(2)如果type不为空时,就进行判断只有指定类型才允许上传

(3)后台不做任何类型校验放开

 

2,解决办法

后台或者前端对文件进行二进制流判断文件的类型

https://segmentfault.com/q/1010000009224378

 

没有标签
首页      前端资源      wordpress教程      移动端使用input type=file时没有type类型判断

随身笔记

移动端使用input type=file时没有type类型判断
js 手机 移动 移动端 input type file type 空 <input id="img1" type="file" name="file" accept="audio/mpeg" /> $('#img1')[0].files[0] //获取到如下图片 在pc端能获…
扫描二维码继续阅读
2019-08-08