faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

0 of 1 people (0%) answered Yes
Recently 0 of 1 people (0%) answered Yes

Entry

I would like to know how to find out the size of a file and then display the filesize.

Apr 7th, 2008 23:01
ha mo, Gaurav Sharma, trixy trixy, Gaurav Sharma


document.fileSize attribute is supported only in MSIE 4 and above. The 
attribute is undefined in the NN document Object.
  var size = document.fileSize;
  var imagesarray = document.images;
  var imglength = 0;
  for (i=0;i<imagesarray.length;i++)
  {
      imglength += imagesarray[i].fileSize;
  }
size will give the size of the html content of the file, images size 
can be found by traversing the images array. Eval the values and add 
them to get the final file size.
var total = eval(size) + eval(imglength);
i hope it helps !!!
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com