is it possible to determine the file size before an actual upload?

I am doing a file upload where I want to constrain the maximum size to 1 mb, and I can check this data after the upload has completed. Is there a way to check this before the upload actually starts?

If you're using mongrel, you can write a handler to get information about the incoming request before it's completely downloaded. You can then have your rails controllers connect to the handler via drb to get the content-length information the browser sends.

Afaik, this is what mongrel's upload progress handler does:

  http://mongrel.rubyforge.org/docs/upload_progress.html

It'll probably do what you need to do. If not, you can use it as inspiration for your own handler.