Home > Web Front-end > JS Tutorial > body text

How to get the size of uploaded file using js

一个新手
Release: 2017-09-20 09:48:50
Original
1575 people have browsed it

HTML:

js获取上传文件的大小:
        <input id="uploadFile" type="file" name="myPhoto"/> 
        <button id="btnConfirm" class="btn" onclick="checkFile()">确认上传</button>
Copy after login

JS:

<script>
        function checkFile() {
          //获取文件 
          var file = document.getElementById("uploadFile").files[0];          
          var vv=file.size;//文件的字节数
          alert(vv)
        }; 
    </script>
Copy after login

The above is the detailed content of How to get the size of uploaded file using js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!