Hi,

I ran into the following issue when installed with entity_browser and media.
I activated DropzoneJsEbWidget, so I believe the issue's going on there.

Problem/Motivation

Whenever I try to upload multiple images with an entity browser, I keep bumping into the error of "At least one valid file should be uploaded" (from the DropzoneJsEbWidget).

Steps to reproduce

* Setup Drupal
* Install Media, Entity browser, Dropzonejs
* Apply this patch for multiple uploads: https://www.drupal.org/project/dropzonejs/issues/2910167#comment-13418933
* Activate above modules + DropzoneJS entity browser widget
* Add an entity browser for multiple images
* Add a media reference field to any given content type
* Upload a couple of images
* Receive the error "At least one valid file should be uploaded"

Proposed resolution

I've discovered that the dropzonejs widget saves the temporary files as txt-files.
These files are attached to the dropzonejs handler in an array, but with all files in a comma separated list.

eg. $files = [
  0 => 'file one.jpg.txt,file two.jpg.txt,...',
  1 => 'file one.jpg.txt,file two.jpg.txt,...'
]

This is the reason why the array is empty, since the separate files cannot be parsed.

That's why I propose to add $file_names = explode(',', $file_names[0]); in DropzoneJS.php (patch follows).

Remaining tasks

* Add $file_names = explode(',', $file_names[0]); in DropzoneJS.php
* Test
* Rejoice

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#2 3164379-1.patch659 bytesblacksnipe
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blacksnipe created an issue. See original summary.

blacksnipe’s picture

Status: Active » Needs review
FileSize
659 bytes

Promised patch.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Looks right to me.

jungle’s picture

Issue tags: +Needs tests

"Needs tests", but I'd rather commit it.

  • jungle committed 9861c56 on 8.x-2.x authored by blacksnipe
    Issue #3164379 by blacksnipe: At least one valid file should be uploaded
    
jungle’s picture

Committed, thanks!

jungle’s picture

Status: Reviewed & tested by the community » Fixed

  • jungle committed 5aaa9c2 on 8.x-2.x
    Revert "Issue #3164379 by blacksnipe: At least one valid file should be...
jungle’s picture

Status: Fixed » Needs work
gwvoigt’s picture

I'm also getting this error with DropzoneJS 8.x-2.4