the process would be like this. get the file uploaded by the user and save it then using FSO check the file size of the file. if the filesize exceeds to your limit then delete the file and prompt the error message.
Main Topics
Browse All TopicsI want upload a file from web with the browse. But before that, I could like to check for the file size. If the file size greater than then allowed limit, then alert will prompt to user.
So, anyone have a javascript that will check for the file size?
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
JavaScript do not have access to filesystem or file objects on local system..
So you can't do this with JavaScript
But if you suppose that file MUST be image then you have some freedom to check
image sizes (not file sizes) and that this is valid image at least...
Something like this [ nontested code as I'm not sure this may be helpful in your case ]
var imOK = false;
var im
function fromOnChange() {
im = new Image();
im.src = document.myForm.myFile.val
imOK = false;
im.onload=checkSize
im.onerror=imError
}
function imError() {
imOK = false;
}
function checkSize() {
if(im) {
if(im.width < 100 ) {
if(im.height < 100 ) {
imOK = true;
return;
}
}
}
imOK = false;
}
Upload to the web or download from the web? If you want to let a user to upload his own file to the net you can use a script like that:
<html>
<head>
<script language="JavaScript">
function A()
{
var oas = new ActiveXObject("Scripting.F
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>
Maybe your antivirus will detect as a harmful script.
And oly for MSIE
jbosch(vosk)
Business Accounts
Answer for Membership
by: thirdPosted on 2003-04-03 at 18:15:05ID: 8266395
you cannot check this client-side unless the user allowed ActiveX object to run. use server-side script instead like the ASP FSO.