Answers.Body: <p>Since you're inside the context of a Matrix block, you'll want to use:</p>
  
  <pre><code>{owner.slug}
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>{slug}
  </code></pre>
  
  <p>More information on that <a href="http://buildwithcraft.com/docs/assets-fields#dynamic-subfolder-paths" rel="noreferrer">http://buildwithcraft.com/docs/assets-fields#dynamic-subfolder-paths</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-28T12:45:00.567Z
Answers.Text: This makes sense but I would have never thought this was necessary. Are there instances where the slug isn't referencing the parent?
Answers.UserDisplayName: Stuart McCoy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-28T14:31:23.800Z
Answers.Text: Sure... when it's not inside of Matrix. :)
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-28T09:29:22.003Z
Answers.LastActivityDate: 2014-06-28T09:29:22.003Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have a Matrix field with two blocks. Each block has an assets field that I'm trying to set to restrict to uploads to a single folder and setting the upload location to {slug}. Basically what I'm trying to do is set up a main folder for my portfolio. I want to be able to upload images for each entry and have them placed in a folder with the same name as the entry so whenI look in Assets I see something like:</p>
  
  <pre><code>Portfolio
  -- project 1 entry name
  -- project 2 entry name
  ...
  -- project 17 entry name
  -- project 18 entry name
  </code></pre>
  
  <p>When I upload the file in my entry form no subfolders are created. I have tried a few things to remedy the problem to no avail. I've set permissions to 777 and have tried placing a / before {slug} because the fileSystemPath variable doesn't have a trailing slash in my general.php config file. Any other issues that might cause this?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-28T04:42:27.280Z
Comments.Text: Stuart, I'm not at all certain you can evaluate {slug} at that point. Especially not if you're uploading from the CP. I suggested elsewhere about assuring a full file system path, but by your naming it appears you've done that. Maybe if you explain a little more specifically what you're doing, one of us can give an idea. Or you'll make it easier for the travelling duo...
Comments.UserDisplayName: narration_sd
Tags: <assets>
Title: Trouble with Restrict to Single Folder and Upload Location
ThreadText: # Trouble with Restrict to Single Folder and Upload Location
  
  (Asked by: username_0 on 2014-06-28)
  
  I have a Matrix field with two blocks. Each block has an assets field that I'm trying to set to restrict to uploads to a single folder and setting the upload location to {slug}. Basically what I'm trying to do is set up a main folder for my portfolio. I want to be able to upload images for each entry and have them placed in a folder with the same name as the entry so whenI look in Assets I see something like:
  
  ```
  Portfolio
  -- project 1 entry name
  -- project 2 entry name
  ...
  -- project 17 entry name
  -- project 18 entry name
  
  ```
  
  When I upload the file in my entry form no subfolders are created. I have tried a few things to remedy the problem to no avail. I've set permissions to 777 and have tried placing a / before {slug} because the fileSystemPath variable doesn't have a trailing slash in my general.php config file. Any other issues that might cause this?
  
  **Tags:** assets
  
  > **Comments:**
  > **username_1**: username_0, I'm not at all certain you can evaluate {slug} at that point. Especially not if you're uploading from the CP. I suggested elsewhere about assuring a full file system path, but by your naming it appears you've done that. Maybe if you explain a little more specifically what you're doing, one of us can give an idea. Or you'll make it easier for the travelling duo...  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-06-28. Score: 6 | Accepted answer
  
  Since you're inside the context of a Matrix block, you'll want to use:
  
  ```
  {owner.slug}
  
  ```
  
  instead of:
  
  ```
  {slug}
  
  ```
  
  More information on that <http://buildwithcraft.com/docs/assets-fields#dynamic-subfolder-paths>
  
  > **Comments:**
  > **username_0**: This makes sense but I would have never thought this was necessary. Are there instances where the slug isn't referencing the parent?  
  > **username_2**: Sure... when it's not inside of Matrix. :)  
  
  ---
  
  