restrict file size before upload
In JSP / HTML, I want to restrict the size of file being uploaded. I've <input type="file" name="myfile"/>
If the size of file more than a specific size say 5MB, i want to give mesage to the user. I don't want to wait till the file gets uploaded to server and then validate the file size. I need client side validation. Can it be done using scripting language or any other way?
I need a solution for this in Internet Explorer. There is already a solution I got using ActiveX control:
var myFSO = new ActiveXObject("Scripting.FileSystemObject");
var filepath = document.getElementById('myfile').value;
var thefile = myFSO.getFile(filepath);
var sizeInBytes = thefile.size;
But ActiveX controls are not allowed in our application. Is there any alternative way for this?
PLease suggest the possible ways.. Thanks in advance!!