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?

CommentFileSizeAuthor
#2 3101967_2.patch1.16 KBmtodor

Comments

joshua.roberson created an issue. See original summary.

mtodor’s picture

StatusFileSize
new1.16 KB

We 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: 251

-      if (!file_prepare_directory($upload_location, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
+      if (!$this->fileSystem->prepareDirectory($upload_location, FileSystemInterface::MODIFY_PERMISSIONS)) {

So, FILE_CREATE_DIRECTORY flag is removed.

I have attached a patch that should fix this problem.

mtodor’s picture

Status: Active » Needs review

  • Primsi committed 7e628cf on 8.x-2.x authored by mtodor
    Issue #3101967 by mtodor: Missing directory upload error
    
primsi’s picture

Status: Needs review » Fixed

Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.