Click to See Complete Forum and Search --> : File size control using JavaScript


jennAshton
09-05-2003, 06:59 PM
Hello JavaScript masters.

I have a formmail script that allow users to upload certain files (You can only get to the form after authencating). Some times the files gets pretty big. So, I would like to limit the file size on the client-end rather than the backend wasting resources. Is this possible using JavaScript? Also, is it possible to use JavaScript to validate their mime type in the client-end as well.

Thanks.

Alien Man
09-05-2003, 08:24 PM
Not sure if this is what you are looking for or not but it's the first thing that came to mind. You will however have to make a change to the code. mytest.txt will have to be replaced with a variable name that will be == to the file being uploaded.

<script type=”text/jscript” language=”JScript”>
<!--
function get()
{
var myObject, f;
// Create an instance of the FileSystemObject.
myObject = new ActiveXObject(“Scripting.FileSystemObject”);
f = myObject.GetFile(“c:\\tmp\\myTest.txt”);
alert(“The file size is: “ + f.Size);
}
//-->
</script>

jennAshton
09-08-2003, 04:30 PM
Thanks Alien man. I will try it out and let you know.

Jenn

Alien Man
09-11-2003, 03:07 PM
Your welcome just hope it was what you were looking for.