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.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | prepare-directory-during-multiple-upload-1904818-8.patch | 602 bytes | haffmans |
| #2 | prepare-directory-during-multiple-upload-1904818-2.patch | 593 bytes | devin carlson |
Comments
Comment #1
ParisLiakos commentednice find:)
care to create a patch?
Comment #2
devin carlson commentedA patch to create the appropriate directory (if it does not exist) before attempting to move the file into it.
Comment #3
ParisLiakos commentedComment #4
devin carlson commentedCommitted to 7.x-2.x.
Comment #5
gmclelland commented@Devin Carlson - I think this commit causes a new problem listed here: #1930950: Plupload integration fails: problem with tmp dir and files
Comment #6
devin carlson commentedReverted #2 as it caused an issue with uploading multiple files.
Comment #7
ParisLiakos commentedthats really weird...
Comment #8
haffmans commentedThe patch in #3 is missing the dirname() around the destination. Attached patch works for me.
Comment #9
aaron commented#1930266: not showing multiple images in edit page Is blocking this issue for me. Unable to review, sorry.
Comment #10
aaron commentedYes,it appears so. I am marking this issue as a duplicate.
Comment #11
khaos119 commentedWhat 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);
Comment #12
gmclelland commentedIf I had to guess I would say it is a duplicate of #2128253: File multiple upload does not respect the field's configuration 'File directory'
The patch in #8 looks very similar to the patch in #2128253-3: File multiple upload does not respect the field's configuration 'File directory'
Comment #13
kenorb commented