Hello all, In JSP / HTML, I want to restrict the size of file being uploaded. <input type="file" name="myfile"/> If the user trying to upload a file size bigger than some value 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 am looking for client side validation. Can it be done using scripting language or any other way? Need a solution for this in Internet Explorer. I got a solution 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!! ---- Poli reddy
Only flash has these capabatilies. Check http://pixeline.be/experiments/jqUploader/test.php where you can specify maximum size of uploaded file.
Thanks Novak. But I cant use Flash becuase it forces IE client to install Flash Player 10+ which is not possible for our application. Could u suggest any other way? Is it possible using Applets?
Yes, it is probably possible via Java applet. Maybe this could work: http://jupload.sourceforge.net/howto-customization.html maxFileSize - This parameter identify the maximum size that an uploaded file may have. It prevent the user to upload too big files.
Thanks a lot Novak.. It worked.. Now I am able to upload bigsize file and get it validated within seconds.. Thanks again!!