cancel
Showing results for 
Search instead for 
Did you mean: 

Error while uploading category image

SOLVED

Error while uploading category image

When I try to upload an image in a category I am getting below error.

 

Screenshot 2024-02-01 161815.jpg

 

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'

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Error while uploading category image

The issue was that the theme was overriding the Magento's default controller.

View solution in original post

Re: Error while uploading category image

The theme controller was overriding the Magento controller. I have modified the controller and fixed the issue.

View solution in original post

3 REPLIES 3

Re: Error while uploading category image

The issue was that the theme was overriding the Magento's default controller.

Re: Error while uploading category image

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,

 

  • Firstly, log in to your Magento Admin.
  • Then, navigate to System > Cache management > Flush Magento cache

Check image roles are assigned to get visible on Admin:

 

  • You can check the assigned roles from the Admin via the below path.
  • Open Product Information > Image Details.
  • Lastly, check "Hide from Product Page" option is not selected. 
If the Favicon icon is not showing on the Admin side, you can try to modify the below file path,
 
/vendor/magento/module-theme/view/adminhtml/ui_component/design_config_form.xml
Then, locate and replace below code snippet:
 
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:
Insufficient PHP memory limit can also cause errors during image upload. You must try updating the limit to some larger value and re-import the image.
 
Re-deploy static content:
If using any custom modules, then connect the server via SSH.
Then, go to the Magento root directory and run the following command,
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
If the issue will be resolved, Click Kudos & Accept as a Solution.

Re: Error while uploading category image

The theme controller was overriding the Magento controller. I have modified the controller and fixed the issue.