Halt file upload if maximum size is reached. Is that possible?

Hi guys.
I’m building a rapidshare-like app, and as such each user has a disk
quota. It’s possible to prevent a file save if it exceeds the free
space, but I searched for an way to do the same during the file
upload. Using flash it’s apparently possible, but I don’t want to use
flash.

One way to do it is via Apache configuration.

But, is there any other way to stop the transfer?

I considered attachment_fu, which says in its config:
“validates_as_attachment – This method prevents files outside of the
valid range (:min_size to :max_size, or the :size range) from being
saved. It does not however, halt the upload of such files. They will
be uploaded into memory regardless of size before validation.”
So, in attachment_fu, this isn’t possible.

MAX_FILE_SIZE worked for PHP, but for Rails, apparently it doesn’t.

Thanks in advance for any help,

Paulo P.