Magento 2 wysiwyg upload error {file} was not uploaded. File validation failed.


The cause of this error in Magento 2 is missing php extension imagick or fileinfo both should be installed on the server

you can check if they are installed by creating new file in your Magento 2 root directory/pub you can name it info.php

and add this to the file

<?php
  phpinfo();

and access it from https://yourdomain.com/info.php

if you can’t find these extensions here

you have to install them

use these commands in your server to install them change php8.3 to your php running version these commands works in ubuntu OS

sudo apt update
sudo apt install php-imagick
sudo apt install php8.3-fileinfo