{"id":1475,"date":"2020-12-21T05:41:16","date_gmt":"2020-12-21T05:41:16","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/solved-disallowed-file-type-when-uploading-product-image-in-magento-2\/"},"modified":"2025-05-21T17:26:29","modified_gmt":"2025-05-21T11:56:29","slug":"solved-disallowed-file-type-when-uploading-product-image-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/solved-disallowed-file-type-when-uploading-product-image-in-magento-2\/","title":{"rendered":"Solved: Disallowed File Type When Uploading Product Image in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In the era of the visual trend, a product image is an essential component of the product page that can grab the buyer\u2019s attention and exerts a real influence on their buying decisions. Potential buyers tend to deep-dive at various angles of images and get a better idea on how the product suits their utility.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/create-simple-product-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">creating a product in Magento 2<\/a>, the admin uploads product images to display on the frontend. Also, he replaces the product images as and when required.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">During the product image upload or replace process, many Magento 2 store owners face a \u201cDisallowed File Type\u201d error. Usually, the error occurs when the wrong image file is uploaded. But sometimes, the \u201cdisallowed file type\u201d error in Magento 2 occurs even when the image file type is correct.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/12\/1-1024x474.jpg\" alt=\"Solved: Disallowed File Type When Uploading Product Image in Magento 2\" class=\"wp-image-12008\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">You can\u2019t leave the product page without images as it affects the shopping experience and conversions. Thus, I have come up with the solution to the error&nbsp;<strong>disallowed file type when uploading product image in Magento 2<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solved: Disallowed File Type When Uploading Product Image in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To solve the error, open&nbsp;<strong>Uploader.php<\/strong>&nbsp;file at&nbsp;<strong><em>vendor\/magento\/framework\/File\/<\/em><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Replace the below line.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>return $this-&gt;fileMime-&gt;getMimeType($this-&gt;_file&#91;'tmp_name']);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>return $this-&gt;_file&#91;'type'];<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it. The disallowed file type error while uploading the product image gets solved just by replacing the code as above.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the era of the visual trend, a product image is an essential component of the product page that can grab the buyer\u2019s attention and&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1475","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1475"}],"version-history":[{"count":2,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1475\/revisions"}],"predecessor-version":[{"id":13913,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1475\/revisions\/13913"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}