Measuring file size with JavaScript -

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

I haven't been able to locate a way to do that in the way you would like to.

You could use your own knowledge of the file size and make each one a variable of some sort:

size_of_image1="40K";

Perhaps someone else has seen a command for it? I couldn't find anything like it on the Netscape JavaScript site.

------------------
John Pollock
http://www.pageresource.com

They have: 5,633 posts

Joined: Jan 1970

Is there a way with JavaScript to measure the size of a file on a server?

eg. Have a value returned to the user like 20kb

------------------
[email protected]
http://www.vegas.com.au/~jasper

They have: 5,633 posts

Joined: Jan 1970

Thanks for your response John.

I have thought about placing the file size within a variable but this is not suitable for what I am trying to do.

I want to use the image size information to give viewers an estimated download time. If I could create this script, I'm sure there would be many web-designers who could benefit from it!

I thought that maybe you could do this with ActiveX. I have no previous experience with ActiveX and if there is anyone out there who can point me in the right direction, I would appreciate it.

------------------
[email protected]
http://www.vegas.com.au/~jasper

They have: 4 posts

Joined: Feb 1999

Depends if you are using ASP, because teh NT host will allow you to create a filesystem object (an activex object) which has a Size method - this is what i use.

They have: 5,633 posts

Joined: Jan 1970

Response to jsharris.

Do you know of any sites where I can get info about ASP and ActiveX?

----------
[email protected]
vegas.com.au/~jasper

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.