Solved

detect file size

Posted on 2001-07-29
8
154 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now