When I try to upload an image in a category I am getting below error.
The issue I found is that the function in the file 'vendor\magento\module-catalog\Model\ImageUploader.php'
public function saveFileToTmpDir($fileId)
is called two times. One with the parameter 'image' and then with the parameter 'thumb_nail'. The error happens when it is called with the parameter 'thumb_nail'. I couldn't find where that function is getting called. It is supposed to be called from the controller 'vendor\magento\module-catalog\Controller\Adminhtml\Category\Image\Upload.php'. But when I comment out the code in the controller it is still being called. And it is supposed to be called one time with the parameter 'image'
Solved! Go to Solution.
The issue was that the theme was overriding the Magento's default controller.
The theme controller was overriding the Magento controller. I have modified the controller and fixed the issue.
Hi @akhilesh4u66f7,
There are various possible reasons that Magento 2 images are not uploading or not showing on the Admin. However, you can try to follow the below ways to fix the error when uploading an image on Magento 2.
Run Re-index Magento Data:
After the import, you might find that uploaded images are not visible at the Admin. It is because some image upload needs to be re-index for the changes to be applied.
Naivgate to System > Index management > Select all > Actions > Update from the save.
Clear the Cache from Cache Management:
You must try to clear your Magento cache and your browser cache,
Check image roles are assigned to get visible on Admin:
/vendor/magento/module-theme/view/adminhtml/ui_component/design_config_form.xml
From: <field name="header_logo_src" formElement="fileUploader"> To: <field name="header_logo_src" formElement="imageUploader"> From: <field name="head_shortcut_icon" formElement="fileUploader"> To: <field name="head_shortcut_icon" formElement="imageUploader">Check PHP memory limit:
php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f php bin/magento indexer:reindex php bin/magento cache:clean