function size(size)
{
var name=['B','KB','MB','GB','TB','PB'];
var pos=0;
while(size>=1204)
{
size/=1024;
pos++;
}
return size.toFixed(2)+" "+name[pos];
}
转载于:https://my.oschina.net/suconghou/blog/271392