Jump to content

Exceeds max allowed file size error on live server


Ivan Gretsky
 Share

Recommended Posts

I got a process module with a file upload field, which used to work fine, but recently started to give me this massage "SomeFile.zip - Exceeds max allowed file size". On the localhost everything works. I did upgrade PW not so long ago. But it seems like it is a server problem. But what is it? What to check? Please help.

Link to comment
Share on other sites

only some thoughts:

what are the settings for upload_max_filesize and post_max_size for PHP?

(maybe you can change them in the .htacces file if you have no access to the php.ini, or you can use the php function ini_set to change them)

what module is it? Does it have settings for max filesize, that maybe gets reset to default on the live server?

does the form, that is used for upload, have a HTML5 setting for MAX_FILE_SIZE ?

<input name="MAX_FILE_SIZE" value="1000000" type="hidden" />
  • Like 1
Link to comment
Share on other sites

Thank you, Horst!

I did check upload_max_filesize and post_max_size. The are both equal to 1047527424.

It is a custom module. I create InputfieldFile like this:

$form = $this->wire( 'modules' )->get('InputfieldForm');
$f = $this->modules->get( 'InputfieldFile' );
$f->name = 'upload_file';
$f->label = $this->_( 'Upload File' ); 
$f->extensions = 'csv jpg db zip';
$f->maxFiles = 2;
$f->maxFileSize	= 0;
$f->unzip = 0; 
$f->overwrite = false;
$f->destinationPath = $path . '.....';
$form->add( $f );

When I echo $f->maxFileSize on localhost it is 104857600, but 5242880 (5MB) on live. Both numbers won't change no matter what i put after $f->maxFileSize  =. Though I can easily change the maxFiles variable. It did work a while ago... What could happen?

Link to comment
Share on other sites

post_max_size integer
Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. Generally speaking, memory_limit should be larger than post_max_size. When an integer is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used. If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action="edit.php?processed=1">, and then checking if $_GET['processed'] is set.
Note:
PHP allows shortcuts for byte values, including K (kilo), M (mega) and G (giga). PHP will do the conversions automatically if you use any of these. Be careful not to exceed the 32 bit signed integer limit (if you're using 32bit versions) as it will cause your script to fail.
Changelog for post_max_size
Version	Description
5.3.4	post_max_size = 0 will not disable the limit when the content type is application/x-www-form-urlencoded or is not registered with PHP.
5.3.2 , 5.2.12	Allow unlimited post size by setting post_max_size to 0.

http://php.net/manual/en/ini.core.php

  • Like 2
Link to comment
Share on other sites

The key is your post max size must be larger than your upload max size, per the PHP manual.  Right now you have both at the same exact size.  I don't know if that will resolve your issue, however the PHP manual says that it must be that way.

Link to comment
Share on other sites

1) I found the problem and the solution. Processwire cannot read post_max_size if it is defined in bytes (see here). It sets it to 5M in that case instead. Define your php_ini variables as 100g, 50m, 1200k, but not as 104857600.

2) And I have not been able to redefine the value due to little typo: it had to be $f->maxFilesize instead of $f->maxFileSize.

  • Like 2
Link to comment
Share on other sites

  • 8 months later...

That was kind of funny, so I decided to share...

Recently I faced the same problem once again and went to the forum search for the answer. How was I surprised to find this topic by myself with a solution by myself present! Of course I did not remember that I already asked that :).

So I decided to come here no more. Went to github, wrote an issue and got the fix from Ryan the same day in the latest release. The moral is if you find a problem and found the solution make sure it is fixed forever in the master code, so you don't have to deal with it ever again. And the way to do it with PW is using github (issues or even better PRs).

All that sound obvious, but may be not so for someone like me thinking that devs read the forums all day long looking for some stuff to fix.

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...