Magento 2 A technical problem with the server created an error. Try again to continue what you were doing. If the problem persists, try again later.

If you are getting this error while trying to upload files from Magento 2 Admin be prepared to spend some time for solving it! Google results regarding this are many and very different, this is because there are many possible reasons for getting it. However if you are lucky you might find the root cause listed here.

Permissions

Because we are trying to upload a file from the Magento Admin, a very possible reason to think about, is that your media folder doesn’t allow write permissions. If you know that you had the right permissions, be aware they were not changed after a migration, cpanel uploads, running commands with sudo, etc..

You can try to set the media directories’ permissions to 777 and check if it solves the problem

find ./pub/media -type d -exec chmod 777 {} \;

Magento Known Bug

Yes, there is already a known bug for this error in older 2.3.x versions , it should be fixed in latest versions. However you can check the following file to confirm if this is the error cause:

vendor/magento/module-theme/view/adminhtml/ui_component/design_config_form.xml

Check lines 154 and 57 :

<field name="head_shortcut_icon" formElement="fileUploader">

If the formElement is as above “fileUploader” then this is the know old issue, you can test replacing it in the above file with the imageUploader. If it solves the issue it means the same old reported issue and you may want to consider upgrade to a newer version.

Admin Role

If you are not sure your admin user has the right role, create a new one, there are many ways to do it we will mention creating it from the command line

bin/magento admin:user:create

Then you will fill the information required by the above command: user, password, email, name.

If this solves your problem, you need to check the resources assigned to your old admin user, or just continue to use the new user if it satisfies your needs.

Server issues

I had gone throw this reason for many times, if you haven’t found your reason between the above mentioned ones, don’t give up you might still be lucky

During the Magento process of listing the media directories, some php functions are used to retrieve information regarding the stored files. for example: mime_content_type(). Which for many reasons can throw undefined function error, due to a different PHP version (yes it was deprecated in some versions), or missing PHP extensions check FileInfo

You can confirm this, by checking the server logs, but if you are using a shared hosting plan you might need to ask the hosting support to assist you.

If you access any CMS block, and open the image uploaded to reproduce the issue on selecting a directory (usually you need to select a directory that contains files to see the error). You can then go to this file

magento/vendor/magento/module-cms/Model/Wysiwyg/Images/Storage.php 

Comment the line 333:

//$item->setMimeType(\mime_content_type($item->getFilename()));

Now if you refresh the image uploader from CMS, you should be able to see the error has disappeared, however this is just to confirm the reason of the issue it is NOT a solution for the upload process, you still need to comment out that line and check the File Info extension or the version of your PHP.

Now, we hope that you found the root cause between the above listed ones, if it is the case or not please feel free to discuss about it in comments

Comments (1)

Wⲟnderful рoѕt! We will be linkinbg to this great content on our ѕite.
Keep upp tthe good writing.

Leave a comment