Newbie and my first question on here. I'm still learning Drupal. So apologies if I missed anything

Here is my issue I am using Webform to create an upload page. The user enters an ID(text field) and uploads the file. The file gets uploaded to a private section on the server. Now I am trying to make sure that the file gets uploaded into this separate folder(named after the ID)( say all/private/ID/). Can I do that using a Webform ? For now, all I can use are basic tokens,not values I can grab from other fields(ex: %username) to create these directories.

If webforms are not the answer, what else would be a good method to go about it ?

1 Answer 1


Greetings welcome to the land of Drupal stuff :)

In general here are some tips:

  • creating a folder off of a textfield ID is going to be cumbersome. How will you know subsequent users aren't putting in the same ID and or overwriting eachothers files?
  • Webform has an API of available hooks. For instance look at webform_submission_presave() which allows you to change/capture a users submitted answer and alter it; you could likely alter the destination of the file to be saved, and assure the destination directory exists with a Drupal API function file_prepare_directory.

If you're looking for an all-in-one no code solution. Look at this issue queue PATCH for webform that looks like it supports custom tokens for upload files.

  • Thank your the suggestions.(Appreciate the warm welcome too). I will take a look into them. I've already looked at the patch you linked to. From what I understand, the custom token support is ust limited to pre-existing basic tokens. The patch creates a directory as soon as you define it, so the tokens will already have to be predefined and existing before you can use it(So %useremail works but %post[key] does not work, it only creates a directory of the same name).
    – Ram
    Jul 22, 2013 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.