0

When I import produt image with .jpg then working correct. But when I upload .jpeg then return Disallowed File Type. when upload product image

Can anyone help how to change I can upload .jpeg?

2 Answers 2

1

can you please check that the PHP module fileinfo is enabled on your environment? usually that's the issue.

LE: also check this older post with a more detailed answer and other possible issues that can cause this. The fileinfo is also mentioned there as a cause of the problem.

Please check and let us know if you managed to solve this.

3
  • How I can check this?
    – Sylvester
    Feb 4, 2021 at 9:04
  • normally, you should check your php.ini file and look for a line with extension=fileinfo.so. if there is a ; in front of it, it means it is disabled and you need to remove it, restart php and recheck your image upload.
    – Diana
    Feb 4, 2021 at 9:10
  • I updated my answer with a link to a resource which might help you (although my money is on the fileinfo module)
    – Diana
    Feb 4, 2021 at 9:15
0

**

While creating a product in Magento 2, the admin uploads product images to display on the frontend. Furthermore, the admin replaces the product images as and when required.

However, some Magento 2 store owners face a "Disallowed File Type" error during the product image upload or replacement process. Usually, the error appears when the wrong image file is uploaded. But sometimes, the "disallowed file type" error in Magento 2 appears even when the image file type is correct.

Thus, you can follow the below solution to fix the "Disallowed File Type" error when uploading a product image,

  • Firstly, open the Uploader.php file from the below file path:

vendor/magento/framework/File/

  • Next, locate and replace the below line,

return $this->fileMime->getMimeType($this->_file['tmp_name']);

With:

return $this->_file['type'];

Hence, the steps mentioned above will help you to fix the "Disallowed File Type" error. However, If the issue persists, you can follow the below solution,

  • Now, you must give 777 permission to pub/media and pub/static folders
  • Lastly, flush the Magento cache and check if the issue persists.

Thus, I hope the above solution helps you to fix the "Disallowed File Type" error when uploading a product image in Magento 2.


Regards,

Rex Maughan

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.