Error message for too-large uploads

i’m trying to send users a polite error message when they try to upload
a file
above a certain size (1.5MB).

we’re using lightpd with rails, and lighttpd is configured to not allow
requests
larger than 1.5MB. that has two flaws: 1.5MB has to be uploaded before i
fails.
i’d like to read the file size before is uploaded, to not waste user’s
time or
our bandwidth. and when the limit is hit, lighttpd just returns a blank
page.
can’t figure out how to get it to return a more useful error message
instead.

any help greatly appreciated, for how to do this in ruby/rails, or
through
lighttpd.config.

best,
john


This message was sent using IMP, the Internet Messaging Program.

I did something something similar with file type restrictions in an
upload page. You could put something l like this in your controller:

def upload

#check the size of the upload file

if size > max_allowed_size
flash [:notice] = “The file is too large to upload”

else
#proceed with file uploading
end

redirect :action => “upload”


Then in your view.rhtml add this:

<% if flash[:notice] %>
<%= flash[:notice] %>
<% end %>

Basically the controller reloads the same upload page. If there is a
message in the flash object it gets displayed in the reloaded page. If
there’s no message in the flash object it doesn’t appear in the page.