I ended up using the IMCE module which was the simplest solution for me, following the Leigh's suggestion.
After installing, I had to click the settings icon on the top right corner in the Manage Form Display page. There is the magic Allow IMCE checkbox.
Projects are built from the start to use the Media module and reference entities instead of files directly. That is how Entity Browser can help.
Here is how it's usually done:
More useful resouces:
As far as I know, there is not a way to add a validation handler for the file field type in general. You'll need to set a hook form alter and add a custom form validate handler for the edit forms, webforms, etc that you want to override.
Refer to: How do I add a custom validation handler to an existing form/field?
Alternatively, if your site is a ...
I ended up creating a new managed file, pretty easy as the following:
$user = \Drupal::currentUser()->id();
$image = File::create([
'uri' => $image_local_path,
'uid' => $user,
'status' => FILE_STATUS_PERMANENT,
This error is often caused by a "stale" autoloader file.
The first and most effective step would be to call
from inside your drupal installation folder (presumably /var/www/sites/drupalroot/) in order to force an updating of the autoloader file in your vendor folder. Try clearing the composer caches as well in combination with this ...
Here are some pointers that might help:
Run drush cr to clear cache and see if the error persists.
Enable error backtraces from the Config > Development > Logging & Errors page to see if you get more info in the error message about where the class is being redeclared.
Search your project for the name MyFormatter and see if you find anything ...
You can override the required = true in file_field_instance_settings_form function that returns and form array and then remove the extensions from your ui config so that drupal use with out the validate function that also checks the resource suffixes.
Same for Drupal 8.
* Implements ...
To load the entity by ID you can use the following code:
/** @var \Drupal\file\FileInterface|null $file*/
$file = \Drupal::entityTypeManager()
But if you need to load the file entity by the given file URI there is a method called loadByProperties in EntityStorageInterface:
/** @var \Drupal\file\...