Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

detect file size

Posted on 2001-07-29
8
Medium Priority
?
167 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 200 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

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!

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one 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…

604 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