I notice something strange and wondered if anyone could check my code on their side and let me know if they get the same thing.
I have a simple simple form (see the full form code and action code below), in which there is only a download button + hidden hash + submit button. The maximum size of the file installed in the file is 10,000,000 (about 9.5 MB).
When I try to upload a file that exceeds the limit, the form should not be checked, but I get an error in the hash mark itself Value is required and can't be empty. Can anyone confirm? It seems like the token is being destroyed. I assume that this can happen in the case of a redirect or something else, but I do not do any redirects if something does not happen in the background, which I do not notice.
Here is the form code and my action code
class Application_Form_TestForm extends Zend_Form
{
public function init()
{
$file = new Zend_Form_Element_File('file');
$file->setDestination(APPLICATION_PATH);
$file->addValidator('Size', false, 10000000);
$file->setMaxFileSize(10000000);
$this->addElement($file);
$hash = new Zend_Form_Element_Hash('hash');
$hash->setIgnore(true)
->setSalt('mysalt');
$this->addElement($hash);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Test')
->setIgnore(true);
$this->addElement($submit);
$this->setAttrib('enctype', 'multipart/form-data');
$this->setMethod('post');
}
}
In my controller I do a normal check
public function indexAction()
{
$form = new Application_Form_TestForm();
$this->view->form = $form;
if($this->_request->isPost()){
echo "post";
if($form->isValid($this->_request->getPost())){
echo " valid";
}
}
}
source
share