detect file size


hi,

could u plz. give me the javascript code to determine the file size?


thanx in advance.

merson
mersonAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
CJ_SConnect With a Mentor Commented:
Javascript is designed to NOT access the client system.

If you do allow ActiveX though, you could use:

filelocation="c:\autoexec.bat"
var fso = new ActiveXObject("Scripting.FileSystemObject")
var file = fso.GetFile(filelocation)
alert(file.ActualSize)

But that will only work if you allow ActiveX and ithe page is not on the internet.

regards,
CJ
0
 
CJ_SCommented:
file size of what?

There are no predefined functions which can tell you the file-size of any page currently loaded...

does that answer your question?

regards,
CJ
0
 
mersonAuthor Commented:


see i want to findout  the size of a file(any images,documents,...etc) in my computer.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
thor918Commented:
hmm cj,
Javascript can be server side too.

But if you want to know the filesize of files on the client side.
You can try this :

bytesize of the document that the script is running from :
document.filesize

and for images :

myImage = new Image();
myImage.src = 'file:///D|/test.gif';
myimage.filesize //will return the image in bytes
0
 
thor918Commented:
But for a detaild file info of your files.. you could run a webserver and use FileSystemObject.

Or you could do like CJ_S said
0
 
COBOLdinosaurCommented:
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
<note>
   In the absence of responses, I may recommend DELETE unless it is clear
   to me that it has value as a PAQ.  Silence = you don't care
</note>

Cd&
0
 
COBOLdinosaurCommented:
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to CJ_S

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 
SpideyModCommented:
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.