The function file_entity_add_upload_multiple_submit() (file_entity.pages.inc) doesn't prepare the upload directory. If the directory doesn't exist, it also doesn't make any attempt to create it. The result is that whenever you try to upload files, you get an error the file cannot be uploaded.

Adding a call to file_prepare_directory(dirname($destination)) just before file_unmanaged_move() fixes the problem (line 215 in the 2.0-unstable7 version).

* Running on OS X (MAMP)
* Media 7.x-2.0-unstable7, plupload 7.x-1.1, Media Multiselect from sandbox (git of today): http://drupal.org/sandbox/fangel/1652676

To reproduce:
* Create an Image field, use Media Multiselect as widget, unlimited cardinality, set (instance's) files directory to something non-existent
* Try to upload some files (using the plupload widget)
* Submit the widget

This will throw the error if the fix is not in place.

Note that the public files directory has all the required permissions, and Drupal is able to upload files directly to that directly without problems.

Comments

ParisLiakos’s picture

Version: 7.x-2.0-unstable7 » 7.x-2.x-dev

nice find:)
care to create a patch?

devin carlson’s picture

Assigned: Unassigned » devin carlson
Status: Active » Needs review
StatusFileSize
new593 bytes

A patch to create the appropriate directory (if it does not exist) before attempting to move the file into it.

ParisLiakos’s picture

Status: Needs review » Reviewed & tested by the community
devin carlson’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x-2.x.

gmclelland’s picture

@Devin Carlson - I think this commit causes a new problem listed here: #1930950: Plupload integration fails: problem with tmp dir and files

devin carlson’s picture

Status: Fixed » Needs review

Reverted #2 as it caused an issue with uploading multiple files.

ParisLiakos’s picture

thats really weird...

haffmans’s picture

The patch in #3 is missing the dirname() around the destination. Attached patch works for me.

aaron’s picture

#1930266: not showing multiple images in edit page Is blocking this issue for me. Unable to review, sorry.

aaron’s picture

Status: Needs review » Closed (duplicate)

Yes,it appears so. I am marking this issue as a duplicate.

khaos119’s picture

What is this a duplicate of? We are having the same issue (not writing new directories with plupload) and that 1 line fixed it.

file_prepare_directory(dirname($destination), FILE_CREATE_DIRECTORY);

kenorb’s picture

Assigned: devin carlson » Unassigned