Magento2: [Magento 2.3.2] Upload fails in image uploader

Created on 28 Aug 2019  路  17Comments  路  Source: magento/magento2

Preconditions:
Magento 2.4-develop
Php 7.3
_fileinfo_ php extension is disabled

Steps to reproduce:

  1. Go to Admin -> Content -> Pages;
  2. Open "Home Page" to edit (for ex.);
  3. Expand the Content tab;
  4. Select the image uploader ("Insert Image" button or the one in the editor);
  5. Select an image from your HD and upload it.

Actual Result: :heavy_multiplication_x: Error: Call to undefined function _mime_content_type()_

:heavy_multiplication_x: An error is shown: "File validation failed." No image is uploaded.

Screenshot from 2020-09-08 10-59-21

Expected Result: :heavy_check_mark: An image must be uploaded without errors

Screenshot from 2020-09-18 15-54-24

The temp uploaded file, i.e., '/tmp/sdfds5we23e', which has no extension, is trying to get the extension thus failing to verify against the validTypes array

FrameworWysiwyg Fixed in 2.4.x Clear Description Confirmed Format is valid Ready for Work P3 done Reproduced on 2.4.x S3

Most helpful comment

This is a duplicate of https://github.com/magento/magento2/issues/16531#issuecomment-405508290

@posttechguy: installing the fileinfo php extension should solve your issue.

In my opinion the fileinfo extension needs to get added to the requirements in the composer.json file of Magento's Framework and the composer.json file of the CMS module

Interested in creating a pull request for this?

All 17 comments

Hi @posttechguy. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@posttechguy do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Hello @posttechguy thank you for your report! I'm not able to reproduce issue on clean Magento 2.3.2 .

Manual testing scenario:

  1. Go to Content -> Pages -> Edit Home page
  2. Add img to Content of CMS Page
    image

Actual result:
Image uploaded without any errors
image

So i have to close this issue. If you have more info please update your issue.

Hi @engcom-Charlie I can confirm that the file upload does not work on 2.3-develop. The reason is that the mime_content_type is removed in 7.1, and while it is checked to see if it exists the getFileExtension is not retrieving the ext because when the file is uploaded to /tmp directory, it saves it without an extension. So there is now way to ascertain whether the file is valid or not.

I have tried it on PHP 7.2.16 also
Screen Shot 2019-08-29 at 9 57 44 am

Bevan

I have also found this bug, on PHP 7.2.16

Fatal error: Uncaught Error: Call to undefined function mime_content_type() in /vagrant/httpdocs/m23-dev/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php:362 Stack trace: #0 /vagrant/httpdocs/m23-dev/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Files.php(60): Magento\Cms\Model\Wysiwyg\Images\Storage->getFilesCollection('/vagrant/httpdo...', 'image') #1 /vagrant/httpdocs/m23-dev/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Files.php(74): Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content\Files->getFiles() #2 /vagrant/httpdocs/m23-dev/app/code/Magento/Cms/view/adminhtml/templates/browser/content/files.phtml(13): Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content\Files->getFilesCount() #3 /vagrant/httpdocs/m23-dev/lib/internal/Magento/Framework/View/TemplateEngine/Php.php(59): include('/vagrant/httpdo...') #4 /vagrant/httpdocs/m23-dev/lib/internal/Magento/Framework/View/Element/Template.php(270): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Cms\Block\Adminhtml\Wysiwyg\Im in /vagrant/httpdocs/m23-dev/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php on line 362

Again calling the removed function mime_content_type

@posttechguy sorry but in my Magento 2.3.2 instance all works fine:
image

This is a duplicate of https://github.com/magento/magento2/issues/16531#issuecomment-405508290

@posttechguy: installing the fileinfo php extension should solve your issue.

In my opinion the fileinfo extension needs to get added to the requirements in the composer.json file of Magento's Framework and the composer.json file of the CMS module

Interested in creating a pull request for this?

Thanks @hostep, that was my issue.

I have added a PR for the issue

Cheers

Adding the fileinfo extension fixed my issue too. This should be added to the requirements page:
https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements-tech.html

:white_check_mark: Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-21825 were created

Issue Available: @engcom-Charlie, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

@magento give me 2.3-develop instance

Hi @krisdante. Thank you for your request. I'm working on Magento 2.3-develop instance for you

Hi @krisdante, here is your Magento instance.
Admin access: https://i-24332-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

Any solution please,
Fatal error: Uncaught Error: Call to undefined function mime_content_type() in /home/public_html/vendor/magento/module-cms/Model/Wysiwyg/Images/Storage.php:331 Stack trace: #0 /home/public_html/vendor/magento/module-cms/Block/Adminhtml/Wysiwyg/Images/Content/Files.php(60): Magento\Cms\Model\Wysiwyg\Images\Storage->getFilesCollection('/home/amarcodex...', NULL) #1 /home/amarcodex/public_html/test/vendor/magento/module-cms/Block/Adminhtml/Wysiwyg/Images/Content/Files.php(74): Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content\Files->getFiles() #2 /home/public_html/vendor/magento/module-cms/view/adminhtml/templates/browser/content/files.phtml(15): Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content\Files->getFilesCount() #3 /home/amarcodex/public_html/test/vendor/magento/framework/View/TemplateEngine/Php.php(59)

@Noman77: please read all the comments, the workaround for now is to install the fileinfo php extension.
See my comment in https://github.com/magento/magento2/issues/24695#issuecomment-534223837

:white_check_mark: Confirmed by @engcom-Alfa
Thank you for verifying the issue. Based on the provided information internal tickets MC-37754 were created

Issue Available: @engcom-Alfa, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

Was this page helpful?
0 / 5 - 0 ratings