I have webforms with validation for many of my fields and they work great.... but none for file size upload.

Example: I have a webform that allows the user to upload a single file. My maximum has been set to 8 MB. However, if the user uploads something greater than 8 MB, the form simply clears itself and returns to a new state (fields are wiped).

A webform validation rule to check if the file is greater than the Max Upload Size BEFORE the upload happens would be very helpful.

Comments

benanne’s picture

Hi, I experienced the same problem with the webform module just now. Please check your apache error logs for messages like this:

[Tue Jun 14 11:36:54 2011] [error] [client XXX.XXX.XXX.XXX] PHP Warning: POST Content-Length of 15224074 bytes exceeds the limit of 8388608 bytes in Unknown on line 0, referer: http://...

This problem can occur because of a 'post_max_size = 8M' in your php.ini file. At least, that was the case for me.

Another posibility is that (one of) your Apache configuration file(s) has a 'LimitRequestBody' directive somewhere that limits the upload size to 8 megabytes.

My problem is now that, although it now shows an error message if the file is too big (instead of simply resetting the form, like you said), the form actually gets accepted because the field is not mandatory... which is not what I wanted. I just came here to look at this model and see if I can use it to do something about this :)

But anyway, I don't want to hijack your issue for that.

Hope this helps.

EDIT: oh, you might need to change 'upload_max_filesize = 8M' in php.ini as well.

svendecabooter’s picture

A validation rule like that could probably be useful. I'll have to check how core handles this.
Although perhaps this is more something that Webform itself should check for, as it's kind of implied functionality when a file component is provided...

I'm currently flooded with work, but i'll look into this later on.

aubjr_drupal’s picture

I added a validation rule for the D6 version as a patch for limiting file uploads. See http://drupal.org/node/1197284 - I haven't done anything for the D7 version, but it could be portable?

liam morland’s picture

Project: Webform Validation » Webform
Version: 7.x-1.0 » 7.x-3.18
Component: Validation rules » Code
Category: feature » bug
Status: Active » Closed (cannot reproduce)

This would be a bug in Webform. However, if it was once a bug there, it seems to be fixed. I cannot reproduce it in the current stable version.