Is it possible to get the file size of the file being submitted before the upload actually starts on Javascript?
A:
No, that's not reliably possible due to security restrictions. You'll need Flash or Java Applet for this. If your intent is just to have a progress bar, have a look at Uploadify or SWFUpload
BalusC
2010-06-05 00:32:39
Looks like those are free apps. What do you mean by "limited resources?"
rockinthesixstring
2010-06-05 00:52:14
Buth are truly free. Where did I said "limited resources"?
BalusC
2010-06-05 12:14:49
A:
Looks like you need the not recommended activex (source: http://www.jguru.com/faq/view.jsp?EID=330134):
<html>
<head>
<script language="JavaScript">
function A()
{
var oas = new ActiveXObject("Scripting.FileSystemObject");
var d = document.a.b.value;
var e = oas.getFile(d);
var f = e.size;
alert(f + " bytes");
}
</script>
</head>
<body>
<form name="a">
<input type="file" name="b">
<input type="button" name="c" value="SIZE" onClick="A();">
</form>
</body>
</html>
k_b
2010-06-05 00:34:00
Can I down vote on principle? Seriously... I know you're trying to be helpful, but ActiveX? I don't think so. Java or Flash will work cross browser which is a nice feature. Some people say Java should die but there are still "some" good uses for it.
rockinthesixstring
2010-06-05 00:41:15
I tested it, and after several warnings from IE, it worked. Didn't work at all in chrome or firefox.
k_b
2010-06-05 00:56:19
A:
I didn't know about this, but you can have a look at this previous post on SO:
theIV
2010-06-05 00:34:21
A:
The relevant feature (The HTML5? File API or what to call it) that is needed isn't fully specified yet. Mozillas implementation can be read at the mozilla developer center
azatoth
2010-06-05 00:54:02