Closed (won't fix)
Project:
Webform
Version:
8.x-5.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Oct 2017 at 13:36 UTC
Updated:
3 Jul 2020 at 12:12 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jrockowitz commentedI deliberately did not expose the #upload_location property for the manage file element because it is not something anyone should customize.
The default file upload location is
://webform/WEBFORM_ID/SUBMISSION_ID, which I strongly feel is the best destination for most webforms. Tracking the webform id and submission id in the file path makes it easy to track and manage uploaded files. For example, I use this pattern to include uploaded files in an exported CSV/archived.@Simon Georges the good news is you can easily set the #upload_location as a custom property. NOTE: This will stop uploaded files from being included in exported submissions.
Here is screen shot of the custom property...
...and you can read the API docs for more information about the #upload_location property.
http://cgit.drupalcode.org/drupal/tree/core/modules/file/src/Element/Man...
Comment #3
simon georges commentedThanks for the fast answer! I'll see if we can use this customization, otherwise, we'll find another way ;-)
Comment #4
mph.arthur commentedThere is an error [The file could not be uploaded because the destination "some/directory" is invalid.] when upload a file.
It created the folder some/directory automatically but it not allow me to upload any file.
Comment #5
jrockowitz commentedThis is most likely a permissions related issue. You need to check the directories permissions. I do not recommend changing the #upload_location.
Comment #6
mph.arthur commentedMy case will receipt 200 applications with photos and music files submitted with the form. I would like the photos and pictures group in specific folder base on they application, so I don't need to pull file from submission id folder one by one.
I also try the input the #upload_location "sites/default/files/private/webform/{webformID}/{submissionID}" which should be the same as default, but still get the same result.
Could you please gave some any suggestion?
Comment #7
kclarkson commentedThis is interesting. I believe webform in D7 had this capability. In situations where people may want to access the files on the backend I could see why you may want organize the files. I am thinking of a situation where we different file uploads where you may want to keep them separated.
Comment #8
andrimont commentedHello to all and thank you @jrockowitz and the maintainers for this stunning work for the Drupal ecosystem.
This post help very much to achieved a good organisation for the uploaded files.
Here's the setting :
upload_location: 'private://organised/path/[some:token]'I understand that @jrockowitz must have good reasons for not exposing the #upload_location property for the manage file element, but for my use, it works so well that way.
Comment #9
andrimont commentedHello @all,
I used this setting to upload files with great success :
upload_location: 'private://organised/path/[some:token]'.But it doesn't work anymore. Instead of a nice path to the uploaded file, I have a weird and double one :
The path was :
1531044/uploaded_file.jpguid being the [current-user:uid]I becomes :
And the uploaded_file.jpg being in the very odd
'[current-user:uid]'folder.How can two folders are created one with the correct value and the other with the token ?
I tried several options like turning off the Sanitize file name. But no success to get the upload files back to the right path.