JS gets the contents of the uploaded file

Source: Internet
Author: User

<div>    Upload file: <input type= "file" name = "file" id = "FileId"/>     <button  type = "Submit" name = "  BTN "value =" commit "id =" Btnid "onclick=" check () "/> Submit </div><script>    function Check () {         var objfile = document.getElementById ("FileId");        if (Objfile.value = = "") {            alert ("Cannot be Empty")        }        Console.log (Objfile.files[0]); File information        var files = $ (' #fileId '). Prop (' files ');//Get to File list        if (files.length = = 0) {            alert (' Select File ');        } else{            var reader = new FileReader ();//Create a new FileReader            Reader.readastext (files[0], "UTF-8");//Read File             Reader.onload = function (evt) {//After reading the file will come back here                var filestring = Evt.target.result;//Read file contents        }    }   }

Note: This content is from http://www.cnblogs.com/chenmo-xpw/p/5629917.html

JS gets the contents of the uploaded file

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.