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

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.
    – magentodev
    Commented Oct 24, 2018 at 20:10
  • Ahhhh, well that's a horse of a different color for sure!
    – dawhoo
    Commented Oct 24, 2018 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.