首页 > input type=file 的 maxLength是多少

input type=file 的 maxLength是多少

var input = document.querySelector("[type=file]");
input.addEventListener('change', function (e) {
    var maxLength = this.maxLength;
    console.log(maxLength);//524288
}, false);

这里的maxLength是浏览器支持的type=file的最大值吗


以下这句话上面也都说到了,就是maxLength对哪些类型的input有效

If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the maximum number of characters (in Unicode code points) that the user can enter; for other control types, it is ignored.

这里解释下524288。这个值是maxLength的默认值,就算你对一个空的input(<input>)进行输出maxLength,也是524288。

w3c说maxLength的默认值是unlimited,但实际上至少在webkit的浏览器上默认值为512KB(524288)。可能因为某种保护措施,但也有人认为这个是webkit的bug。

google以下,啥都有


你这个图表连接可以给我看下么?


借地儿问下,file如果上传的是图片,怎么限制选中上传的图片数量?


type=file是用于选取文件的,不具有maxLength这属性,input的type为text,url,email,password等文字编辑型的才具有maxLength属性,表示最大可输入长度,超出此长度就无法输入了


maxlength和minlength支持的type类型为:text,tel,url,email,password,以及search。当type=file时,maxlength是没有效果的,标准如下:

【热门文章】
【热门文章】