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
larger than 1.5MB. that has two flaws: 1.5MB has to be uploaded before i
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
can’t figure out how to get it to return a more useful error message

any help greatly appreciated, for how to do this in ruby/rails, or


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”

#proceed with file uploading

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs