I am working on a web application which supports file uploading. I am already familiar checking the size in server side, but i wanted to check the file size in a client side.
After lot of searching i found we can use maxAllowedContentLength to limit the upload size in ASP.Net applications. Remember this settings work only on IIS 7 or above.
Since this is handled in IIS level, we dont need to handle anything in server code. If the size limit exceeds, it will return the error code 404.13. So you can easily check the code in client side to determine the problem.
This is what i have done to handle the large files if the flash is not installed in the client machine.
Hope this may help someone.
For more info read about this settings, read this
In IE, you can do it with JS and ActiveX:
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>
I'll start off by saying that I haven't been able to generate a working copy and most of this is my understanding from reading around and slight expirience. That said, perhaps you could explore it a bit more and/or set me straight if I'm wrong.
The main thing points to the idea of the classic form with a hidden input named MAX_FILE_SIZE... In PHP/Apache, the server will stop if the upload is larger than the MAX_FILE_SIZE (see last post from here). On the PHP side of things, the $_FILES array will return an error code (which can be seen here). Take note of UPLOAD_ERR_FORM_SIZE.
To put this all together, you could have JavaScript upload the file within an IFrame and get the result. If the server spits out an error message (which, in this theory, would be quite quickly), JavaScript can simply alert the user. Otherwise, we can assume the file is now uploaded successfully. Now trying to make sense of Google's code is near impossible; a quick HTML scan is as far as I go and it didn't help any... They do indeed have hidden input fields but none with MAX_FILE_SIZE as the name. They are much shorter and most don't appear to have values. But, I believe this could be possible. Thoughts anyone?
Who knows, perhaps the great Google Web Server is built in with the power to cut off uploads instantly. Thanks for listening!
lol ofc you can do it, it's just a bit of hardwork, if you search for "uploadbar flash" instead of using the data you retrieve to create a uploader you could use it to pass it on or compare or do whatever you want the one i found that seemed quite good is this one, it doesnt necceraly use flash but you could use it to achive the same thing http://www.plupload.com highly configurable p.s. you could force it to just use flash if you really like