Javascript-h5 multiple images uploaded, on the mobile side of the solution?

Source: Internet
Author: User
The recent project to do a side of the voting function, which involves multi-image upload, I tried to use FileReader to make, in the PC-side test when normal operation, but in the end encountered a variety of pits, to find answers, the following is my question and code
Problems encountered:
1, in the Android when the choice is not on
2, in the iOS side of the time to choose more, but will be stuck in the error prompt there, is the following code "return alert" ("Upload the image is not the correct format, please re-select") ",

This is the HTML code

    

This is the JS code

    window.onload = function(){        var input = document.getElementById("file_input");        var result,div;         if(typeof FileReader==='undefined'){            result.innerHTML = "抱歉,你的浏览器不支持 FileReader";            input.setAttribute('disabled','disabled');        }else{            input.addEventListener('change',readFile,false);        }            function readFile(){            for(var i=0;i
  
   < code="">

Reply content:

The recent project to do a side of the voting function, which involves multi-image upload, I tried to use FileReader to make, in the PC-side test when normal operation, but in the end encountered a variety of pits, to find answers, the following is my question and code
Problems encountered:
1, in the Android when the choice is not on
2, in the iOS side of the time to choose more, but will be stuck in the error prompt there, is the following code "return alert" ("Upload the image is not the correct format, please re-select") ",

This is the HTML code

    

This is the JS code

  window.onload = function () {var input = document.getElementById ("fil        E_input ");         var Result,div;            if (typeof filereader=== ' undefined ') {result.innerhtml = "Sorry, your browser does not support FileReader";        Input.setattribute (' disabled ', ' disabled ');        }else{input.addeventlistener (' Change ', readfile,false); } function ReadFile () {for (var i=0;i 
     " div= "document.createelement ('        Div '); "div.innerhtml=" result; "document.getElementById (' Picupload '). appendchild (Div); }}}< code>
      

Side can use the upload picture interface ...

Our original project useful Ajaxfileupload implementation, at the end should be no problem, if it is a native hybrid architecture, some models such as Millet is not supported.

PS: I seem to see the wrong topic, is to choose more pictures at the same time, I think it is more than one choice, the main ignore it.

Android does not support multi-image selection, this pit has been trampled before.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.