A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Engineering
»
HTML, CSS and JavaScript
Author
not able to get uploaded file size in javascript
kavita vala
Ranch Hand
Joined: Jul 22, 2010
Posts: 42
posted
Aug 06, 2010 01:22:22
0
I want to know the client document size before it uploaded to browser
I have a code given below.
Javascript function
function getfilesize() { alert('hi size check') var oas = new ActiveXObject("Scripting.FileSystemObject"); alert('1') var d = document.form.b.value; alert('2') var e = oas.getFile(d); alert('3') var f = e.size; alert(f + " bytes"); }
and html code is
<div> <input type="file" name="b"> <input type="button" name="c" value="SIZE" onClick="getfilesize();"> </div>
I get first alert('hi size check') but from second line it cant work
Please help me.
Thanks in advance
Lester Burnham
Rancher
Joined: Oct 14, 2008
Posts: 1337
posted
Aug 06, 2010 02:00:44
0
What do you mean by "it can't work"? What
exactly
happens? Are there error messages in the Console?
kavita vala
Ranch Hand
Joined: Jul 22, 2010
Posts: 42
posted
Aug 06, 2010 02:07:28
0
No there is no error message but. But the second alert is not come so.
an error is in
var oas = new ActiveXObject("Scripting.FileSystemObject");
line but i could not able to find
Is there any other code to write for use above statement
Lester Burnham
Rancher
Joined: Oct 14, 2008
Posts: 1337
posted
Aug 06, 2010 02:10:04
0
Hard to tell what's happening if you don't tell us what error is occurring. You're aware that this will only work in IE, right?
kavita vala
Ranch Hand
Joined: Jul 22, 2010
Posts: 42
posted
Aug 06, 2010 03:13:26
0
ya but it cant work in ie also. Is there any other way that i should get the size of
Loaded file.
Please help me for this issue
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
6
posted
Aug 06, 2010 05:56:40
0
Where did you learn about .sie()? Did you make it up thinking it would work?
Eric
I agree. Here's the link:
http://aspose.com/file-tools
subject: not able to get uploaded file size in javascript
Similar Threads
Need help with Jquery
problem when integrating jspell with tinyMCE editor
JSF with fileupload and iframe
jQuery not working on page
preview of an image for uploading in firefox
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter