3

I am integrating file uploader in admin form. It's working fine. but it has default 2MB upload file size limit.

This is my uploader class

public function __construct(
    ....
    \Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory,
    ....
) {
    ....
    $this->_fileUploaderFactory = $fileUploaderFactory;
    ....
}

public function uploadFile($scope)
{   
   try {
        $uploader = $this->_fileUploaderFactory->create(['fileId' => $scope]);
        $uploader->setAllowRenameFiles(true);
        $uploader->setFilesDispersion(true);
        $uploader->setAllowCreateFolders(true);

        if ($uploader->save($this->getBaseDir())) {
            return $uploader->getUploadedFileName();    
        }

    } catch (Exception $e) {
        throw new \Exception('The file was not uploaded.', $code);
    }
    return '';
}

How we increase file uploader limit?

2
  • Please check "upload_max_filesize" in phpInfo() – Sarfaraz bheda May 13 '17 at 13:06
  • yes, it is working. – ketan patel May 13 '17 at 13:14
5

I think there is no Default setting in code:

Just update php.ini settings:

memory_limit = 32M
upload_max_filesize = 24M
post_max_size = 32M

Hope this will work!!

1
  • Just to add, my php.ini was found at /etc/php/7.2/apache2/php.ini which can be determined by adding a file containing this <?php phpinfo(); ?> to the root of the server and browsing to it. As a final note, run service apache2 reload to get the changes to take effect. – Daniel Black Nov 6 '19 at 15:13
0

I have a strange problem. We have our post_max_size set to 32M in our PHP ini. (php 7.2) But when I goto upload our logo in Content/Design/Config it says "Max limit 1kb"

Where is Magento getting that value?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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