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 

相关文章:

  • 2022-12-23
  • 2021-11-24
  • 2022-12-23
  • 2022-02-06
  • 2021-06-22
  • 2021-12-18
  • 2022-01-17
  • 2021-11-03
猜你喜欢
  • 2022-01-04
  • 2022-12-23
  • 2021-12-29
  • 2021-11-11
  • 2021-12-15
  • 2022-12-23
  • 2021-11-11
相关资源
相似解决方案