1.input默认单选,开启多选:加上multiple属性
2.也可以利用form上传
enctype属性规定在发送到服务器之前应该如何对表单数据进行编码
默认编码是:application/x-www-form-urlencoded对于普通数据时挺适用的,但是对于文件,就不能乱编码了,只能使用multipart/form-data作为enctype属性值
3.input控件不美观,可以利用label for id关联
4.accept属性:用来指定浏览器接受的文件类型,打开系统的选择文件弹框的时候,默认界面中呈现的文件类型
accept="image/jpeg",则界面中只有jpg图片,只限定jpg图片上传,太局限性了
accept="image/*",在界面中能够看到所有的图片,但选择文件可能有点慢,仅仅图片可以用以下方式:accept="image/png, image/jpeg, image/gif, image/jpg"
5.只选择文件夹
webkitdirectory directory multiple
<label for="image">照相机</label>
<input type="file" id='image' accept="image/*" capture='camera' multiple>
<br>
<hr>
<hr>
<label>录音</label>
<input type="file" accept="audio/*" capture="microphone">
<br>
<hr>
<hr>
<label>摄像机</label>
<input type="file" id='video' accept="video/*" capture='camcorder' multiple>
网友评论