I am using Drupal 8.8.0 with PHP 7.3. I have a field setup on a content type to allow drag-and-drop of a file into the field. When I drag a file and click "Select entities", I get this error:
Files could not be uploaded because the destination directory private://exclusive/[date:custom:Y]/[date:custom:m] is not configured correctly.
No file is listed, just the error. It should upload the file to this directory: "private://exclusive/2019/12". When I repeat the process a second time, it works.
I found that the error only occurs if the "exclusive/2019/12" directory doesn't exist when attempting the upload. Once it exists, everything works fine even if I add a second node and upload another file.
It is related to code in this file:
modules/eb_widget/src/Plugin/EntityBrowser/Widget/DropzoneJsEbWidget.php
if (!$this->fileSystem->prepareDirectory($upload_location, FileSystemInterface::MODIFY_PERMISSIONS)) {
$form_state->setError($form['widget']['upload'], $this->t('Files could not be uploaded because the destination directory %destination is not configured correctly.', ['%destination' => $this->getConfiguration()['settings']['upload_location']]));
}
It seems like "prepareDirectory()" creates the directory on the first try, so maybe showing that error isn't necessary or maybe only needed in certain cases where it couldn't create the directory at all?
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3101967_2.patch | 1.16 KB | mtodor |
Comments
Comment #2
mtodor commentedWe have noticed this problem in Thunder test for image upload in the entity browser. And after some investigation, we found a small mistake in Drupal 9.0 deprecation changes - #3042624: Drupal 9 Deprecated Code Report.
File:
modules/eb_widget/src/Plugin/EntityBrowser/Widget/DropzoneJsEbWidget.php- Line: 251So,
FILE_CREATE_DIRECTORYflag is removed.I have attached a patch that should fix this problem.
Comment #3
mtodor commentedComment #5
primsi commentedThanks.