Answers.Body: <p>That field accepts any valid Twig code, so something like this should work:</p>
  
  <pre><code>challenges/{{ craft.request.getPost('challenge_id') }}/
  </code></pre>
  
  <p>Fair warning, though... I'd also be wary of accepting untrusted front-end input like this that ends up on the file system.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-17T15:32:26.947Z
Answers.Text: This seems pretty dangerous, unless Craft automatically prevents users from writing to directories outside the install (i.e. a user in the front-end passing in `../../../usr/bin/` or something malicious)…
Answers.UserDisplayName: August Miller
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-17T20:24:23.110Z
Answers.Text: Craft does some bounds checking for situations like this, but I added the warning in my initial comment to the answer, too.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-15T17:17:17.157Z
Answers.LastActivityDate: 2017-04-17T18:48:40.417Z
Answers.LastEditDate: 2017-04-17T18:48:40.417Z
Answers.UserDisplayName: Brad Bell
Body: <p>How can I use a request variable used in an upload form like this?</p>
  
  <pre><code>&lt;form method="post" accept-charset="UTF-8" enctype="multipart/form-data"&gt;
  &lt;input type="hidden" name="action" value="entries/saveEntry"&gt;
  &lt;input type="hidden" name="sectionId" value="29"&gt;
  &lt;input type="hidden" name="enabled" value="1"&gt;
  &lt;input type="file" name="fields[useruploads]"&gt;
  &lt;input type="text" name="challenge_id"&gt;
  ...
  </code></pre>
  
  <p>The idea is to use the field "challenge_id" as dynamic upload location.</p>
  
  <p><a href="https://i.sstatic.net/2oQYf.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2oQYf.png" alt="enter image description here"></a></p>
  
  <p>Is there a way to get this?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-13T18:37:51.820Z
Comments.Text: Try something like `challenges/{{ craft.request.getPost('challenge_id') }}/`? I'd also be wary of accepting untrusted front-end input like this that ends up on the file system.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-15T14:30:24.487Z
Comments.Text: @Brad Bell: it works - the hint hearby the field "... like {slug] or ..." is misleading, because I have done all my tries with one curly brace.
Comments.UserDisplayName: Marco
Tags: <upload><request><files>
Title: Use REQUEST variable as dynamic upload location
ThreadText: # Use REQUEST variable as dynamic upload location
  
  (Asked by: username_0 on 2017-04-13)
  
  How can I use a request variable used in an upload form like this?
  
  ```
  <form method="post" accept-charset="UTF-8" enctype="multipart/form-data">
  <input type="hidden" name="action" value="entries/saveEntry">
  <input type="hidden" name="sectionId" value="29">
  <input type="hidden" name="enabled" value="1">
  <input type="file" name="fields[useruploads]">
  <input type="text" name="challenge_id">
  ...
  
  ```
  
  The idea is to use the field "challenge\_id" as dynamic upload location.
  
  [![enter image description here](https://i.sstatic.net/2oQYf.png)](https://i.sstatic.net/2oQYf.png)
  
  Is there a way to get this?
  
  **Tags:** upload, request, files
  
  > **Comments:**
  > **username_1**: Try something like `challenges/{{ craft.request.getPost('challenge_id') }}/`? I'd also be wary of accepting untrusted front-end input like this that ends up on the file system.  
  > **username_0**: @username_1: it works - the hint hearby the field "... like {slug] or ..." is misleading, because I have done all my tries with one curly brace.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-04-15. Score: 1 | Accepted answer
  
  That field accepts any valid Twig code, so something like this should work:
  
  ```
  challenges/{{ craft.request.getPost('challenge_id') }}/
  
  ```
  
  Fair warning, though... I'd also be wary of accepting untrusted front-end input like this that ends up on the file system.
  
  > **Comments:**
  > **username_2**: This seems pretty dangerous, unless Craft automatically prevents users from writing to directories outside the install (i.e. a user in the front-end passing in `../../../usr/bin/` or something malicious)…  
  > **username_1**: Craft does some bounds checking for situations like this, but I added the warning in my initial comment to the answer, too.  
  
  ---
  
  