首页 > 其他分享 >input的file一些实用属性

input的file一些实用属性

时间:2022-12-06 16:23:29浏览次数:32  
标签:multiple log console 实用 文件格式 file input 写法

 

 

  file自带一些有用的属性,今天整理一下

  html:

  1.multiple:是否多选,如果在html上面写上multiple="multiple"或者multiple就可以实现多选

  2.accept:文件格式,这个可以控制文件格式,比如jpeg和gif还有Png之类的,写法是这样的<input type="file" accept="image/png,image/gif,image/jpeg" />

  js:

  1.name:文件名字,一般写法是这样的

  console.log(img.files[0].name) //img2.jpg

  2.size:选择文件的大小,写法如下

  console.log(img.files[0].size) //15781 

标签:multiple,log,console,实用,文件格式,file,input,写法
From: https://www.cnblogs.com/SadicZhou/p/16955632.html

相关文章