网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

javascript实现移动端上传图片功能的方法-创新互联

这篇文章主要介绍javascript实现移动端上传图片功能的方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

10年积累的成都做网站、网站制作、成都外贸网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有长宁免费网站建设让你可以放心的选择与我们合作。

核心部分(.html)

window.onload = function() {
 let fileTag = document.getElementById('file');
 // console.log(fileTag)
 // console.log(this.pic)
 let that = this
 
 fileTag.onchange = function() {
  let file = fileTag.files[0];
  let fileReader = new FileReader();
  // console.log(file)
  console.log(fileReader)
  // console.log(that.pic)
  fileReader.onloadend = function() {
  console.log(1212)
  if (fileReader.readyState == fileReader.DONE) {
   // console.log(that.pic)
   console.log(fileReader)
   
   if(that.pic=="") {
   console.log(1111)
   that.pic = fileReader.result
   that.input1 = false
   
   that.upLoad(fileReader.result)
   return
   }else{
   if(that.pic2=='') {
    console.log(2222)
    that.pic2 = fileReader.result
    that.input2 = false
    return
   }else {
    if(that.pic3=='') {
    console.log(3333)
    that.pic3 = fileReader.result
    that.input3 = false
    return
    }else {
    if(that.pic4=='') {
     console.log(4444)
     that.pic4 = fileReader.result
     that.input4 = false
     return
    }else {
     console.log(5555)
     if(that.pic5=='') {
     that.pic5 = fileReader.result
     that.input5 = false
     return
     }
     
    }
    }
   }
   
   }
   // console.log(that.pic)
  }
  };
  
  fileReader.readAsDataURL(file);
 }
} 

文章标题:javascript实现移动端上传图片功能的方法-创新互联
网站URL:http://bjjierui.cn/article/edsgi.html

其他资讯