zoukankan      html  css  js  c++  java
  • js获取文件大小


    var file = urlBox.doc.activeElement.files[0]||urlBox.files[0] ;
    if (file) {
    var fileSize = 0;
    if (file.size > 1024 * 1024) {
    fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
    }
    else {
    fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';
    }
    }

    上面的代码是chrome浏览器获取文件大小的方法。

  • 相关阅读:
    数学
    数学
    Computer Science
    数学
    Computer Science
    元学习
    数学
    数学
    数学
    数学
  • 原文地址:https://www.cnblogs.com/Tpf386/p/6137703.html
Copyright © 2011-2022 走看看