Does anyone know if there is a way to check the size of a file (a picture in my case) that the user can upload from a form *BEFORE* the file is uploaded?
-----One obvious solution is to check the HTTP content-length of the file POST request and cancel the upload if it's too big (throw a ServletException for example). The problem is that I think IE doesn't care if the server has stopped receiving the file and continues to upload it anyway.
If I remember right, the Image object loading is asynchronous, so you might need to define an onload function that will be called when the file is actually loaded.
I do think, though, that providing a server-side check is preferable.