Inside my form i define this file upload field:
$this->setEnctype(Zend_Form::ENCTYPE_MULTIPART);
$logo = $this->createElement('file', 'logo');
$logo->setLabel('Group logo')
->setMaxFileSize(5242880) // 5mb
->addValidator('IsImage')
->addValidator('Count', false, 1)
->addValidator('Size', false, 5242880)
->addValidator('Extension', false, array('jpg', 'jpeg', 'png', 'gif'));
However, no matter how small files I upload I get this error: File 'logo' exceeds the defined ini size.
The error message seemed pretty straight forward so I checked the php config (phpinfo() on the same exact page that handles the form)
While those values don't exactly make sense, they absolutely should allow me to upload files up to 8Mb but the upload always failes with the message from above. Even files smaller than 1Kb fail. I also tried removing all setters/validators but it still fails.
While searching for an answer I came across some posts that said that it was ajax' fault but this is a regular form, so now I'm stuck.
Update: I'm terribly sorry to have wasted your time, there was another unclosed form on the page which voided the multipart-declaration. Could have found that out sooner if I had tested with larger files rather than small ones :/
That means if you try to upload a file larger than that limit, you’re going to see the “the uploaded file exceeds the upload_max_filesize directive in php.ini”, or a similar message like “ file_name exceeds the maximum upload size for this site .” In order to fix this error, you need to increase the file size upload limit.
Another class used in file uploading is Zend\Filter\File\RenameUpload. The RenameUpload is used to move the uploaded file to our desired location. The partial class to use file filter is as follows −
This maximum, in megabytes, is defined in the upload_max_filesize directive. The upload_max_filesize directive itself is located in the php.ini file, which is the default server configuration file for applications that require PHP. Those two things – upload_max_filesize and php.ini – are what the error message you see is referencing.
In order to fix this error, you need to increase the file size upload limit. That is, you need to increase the value of the upload_max_filesize directive in your php.ini file. There are several different ways you can do this – the exact method that you choose will depend on your preference and your host’s configuration.
Add enctype="multipart/form-data"
in your form. It should solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With