Solved

detect file size

Posted on 2001-07-29
8
159 Views
Last Modified: 2008-03-17

hi,

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


thanx in advance.

merson
0
Comment
Question by:merson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 6333284
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
 

Author Comment

by:merson
ID: 6333297


see i want to findout  the size of a file(any images,documents,...etc) in my computer.
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 50 total points
ID: 6333429
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:thor918
ID: 6729106
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
 
LVL 2

Expert Comment

by:thor918
ID: 6729109
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7910439
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 8000255
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
 

Expert Comment

by:SpideyMod
ID: 8068483
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question