phpzend-frameworkzend-file

PHP, Zend Framework: How to set the upload max filesize?


I'm setting the upload max filesize in my form:

$file = new Zend_Form_Element_File('file');
$file->setLabel('File to upload:')
    ->setRequired(true)
    ->addValidator('NotEmpty')
    ->addValidator('Count', false, 1)
    ->addValidator('Size', false, 10485760) //10MB = 10,485,760 bytes
    ->setMaxFileSize(10485760)
    ->setDestination(APPLICATION_UPLOADS_DIR);
$this->addElement($file);

But I'm getting this error message in my Zend Framework application:

Notice: Your 'upload_max_filesize' config setting limits the maximum filesize to '2097152'. You tried to set '10485760' in /location/to/Zend/Form/Element/File.php on line 620

What am I doing wrong?


Solution

  • The upload_max_filesize is an option in the configuration of PHP itself, and independant of Zend Framework.

    If you need to modify that max upload size, you should set it in your php.ini file -- note you'll certainly also have to modify post_max_size.