1

I'm trying to restrict the weight of the uploaded file in admin, I found the 'maxFileSize' in Magento documentation but it's not working :

$fieldset->addField( 'files', 'file', [ 'name' => 'file', 'label' => __('File'), 'title' => __('File'), 'maxFileSize' => 2097152, 'required' => false, 'note' => 'File size must be less than 2 Mb.' ] ); 

Thanks !

2
  • you can restrict it from controller save action. Commented Oct 24, 2018 at 18:29
  • Check out this link where maxfilesize is being used in the form field: magento.stackexchange.com/questions/193784/… Commented Oct 24, 2018 at 22:41

1 Answer 1

0

I think I would use php.ini instead.

To ensure that file uploads work correctly, the post_max_size directive should be a little larger than the upload_max_filesize. For example, the following settings demonstrate how to set a file upload limit to 20 megabytes:

upload_max_filesize = 20M post_max_size = 21M 
2
  • 1
    Thanks for your answer but by doing this I will limit all files fields and I just want to custom the max size for this specific field. Commented Oct 24, 2018 at 20:10
  • Ahhhh, well that's a horse of a different color for sure! Commented Oct 24, 2018 at 22:23

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.