File upload: size check or setMaxFileSize ()

For Zend_Form_Element_File, is there a difference between adding a size check parameter and using setMaxFileSize?

$file->addValidator('Size', false, 1000000);

$file->setMaxFileSize(1000000);
+3
source share
1 answer

setMaxFileSize (1000000) will limit the size on the client side, i.e. a special tag MAX_FILE_SIZE will be created in html, for example:

 <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />

However, this is not so safe because it is easy to modify html. In any case, if you do not specify setMaxFileSize, ZF will automatically create it with a value equal to the upload_max_filesize value in php.ini.

AddValidator , html. .

+5

Source: https://habr.com/ru/post/1787599/


All Articles