JS 小腳本匯聚

  1. 根據文件length展現文件大小
    if (bytes === 0) 
        return '0 B';
    var k = 1024,
    sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    i = Math.floor(Math.log(bytes) / Math.log(k));
    return (bytes / Math.pow(k, i)).toFixed(1) + sizes[i];
相關文章
相關標籤/搜索