Solved

detect file size

Posted on 2001-07-29
8
157 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

774 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