Tuesday, March 10, 2015
Java Script util function to get bytes of file size from KB and MB
var convetFileSizeInBytes= function (size) {
var totalSize=0;
var kilobyte = 1024;
var megabyte = kilobyte * 1024;
if(size.indexOf("b")>0){
totalSize=size.replace('b','');
}
if(size.indexOf("KB")>0){
totalSize=size.replace('KB','');
totalSize= Math.round(totalSize*kilobyte);
}
if(size.indexOf("MB")>0){
totalSize=size.replace('MB','');
totalSize= Math.round(totalSize*megabyte);
}
return totalSize;
};
call above if ur inputs like this convetFileSizeInBytes("10KB");
you will get byte values and you can use that for validation
Subscribe to:
Comments (Atom)