Answers.Body: <p>This answer really belongs to Brad, as he mentioned it to me. But he doesn't really need the points, does he ;)</p>
  
  <p>What you want in that slot is {owner.slug}, and then the proper sub-path will ensue.</p>
  
  <p>The explanation is deep in the doc page at: <a href="http://buildwithcraft.com/docs/assets-fields">http://buildwithcraft.com/docs/assets-fields</a></p>
  
  <p>To wit, </p>
  
  <blockquote>
    <p>"Note that if you are creating the Assets field within a Matrix field,
    the source element is going to be the actual Matrix block, not the
    element that the Matrix field is being created on. So if your Matrix
    field is attached to an entry, and you want to output the entry ID in
    your dynamic subfolder path, you would type {owner.id} not just {id}."</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-18T03:23:00.873Z
Answers.Text: You get the rep fair and square. :) Didn't even think it might be in a Matrix field.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-18T07:41:38.137Z
Answers.Text: I did rather make the assumption, didn't I...but the reason is that the only place {slug} is mentioned in this fashion is in the form for Matrix images. Really, it should say {owner.slug} there to be correct, shouldn't it?
Answers.UserDisplayName: narration_sd
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-18T14:12:46.620Z
Answers.Text: That's a good point for matrix fields. However I'm still having the same problem for non-matrix fields after making the file system path absolute.
Answers.UserDisplayName: Alex H
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-18T14:20:35.850Z
Answers.Text: The correct subfolder is created in the filesystem, but as the root 'Local storage' location is highlighted when I open the 'Add an asset' dialog it adds it there.  If I highlight the correct folder manually I get an error where there is a double directory separator slash: 'Error uploading the file: The folder "/home/apps/test/public/cms/images/heroes//history/" does not exist.'  I've double checked and there don't seem to be any trailing slashes on the paths I've set.
Answers.UserDisplayName: Alex H
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-18T15:02:48.250Z
Answers.Text: Ah, I understand now that this default upload location will only be used if the asset is dragged onto the field, or the 'Restrict uploads to a single folder?' is checked. I'm still getting the double slash error though.
Answers.UserDisplayName: Alex H
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-18T16:39:36.080Z
Answers.Text: Hmm. I actually have a trailing slash on both my Asset file system path and web url. If I use {slug} in an ordinary Assets field and drag-drop an image, things work as expected, no double slash error, and the image ends up in the directory associated with the page slug. This also works if I take the trailing slash off. Maybe try this with devMode true in general.php, then send a support request from the CP with logs included as should be automatic, so Brad can look at your circumstance?
Answers.UserDisplayName: narration_sd
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-18T16:42:18.953Z
Answers.Text: Another little interesting point is that the Assets dialog actually put the trailing slash back into the file system path when I saved it. So I wonder what version of Craft you are running? Latest 2.2.2601 here.
Answers.UserDisplayName: narration_sd
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-19T11:11:56.477Z
Answers.Text: I'm running 2.2.2601. This was a permissions issue of being unable to create the folder rather than a problem with the double slashes. Many thanks for your help on this.
Answers.UserDisplayName: Alex H
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-19T17:52:41.887Z
Answers.Text: There you go, and most welcome, Alex.
Answers.UserDisplayName: narration_sd
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-18T03:07:55.580Z
Answers.LastActivityDate: 2014-11-18T03:07:55.580Z
Answers.UserDisplayName: narration_sd
Body: <p>I have a local asset folder defined with name 'Local storage' file system path <code>../public/cms/images/</code>, and URL <code>/cms/images/</code>.</p>
  
  <p>I create an Assets field named 'Hero image', not restricted to a single folder, with source 'Local storage', and default upload location 'Local storage' with path <code>heroes/{slug}/</code>.</p>
  
  <p>I'd expect uploads for Hero image to land in the <code>/public/cms/images/heroes/{slug}</code> folder. When I do upload an asset, this folder is created, yet the asset lands in the root <code>/public/cms/images</code> folder.</p>
  
  <p>Why might this be?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-11-17T17:30:27.190Z
Comments.Text: Try using absolute paths/URLs and see if that works. You probably just have a relative path setup incorrectly somewhere.
Comments.UserDisplayName: Brad Bell
Tags: <assets>
Title: Uploaded assets not saving in specified local folder
ThreadText: # Uploaded assets not saving in specified local folder
  
  (Asked by: username_0 on 2014-11-17)
  
  I have a local asset folder defined with name 'Local storage' file system path `../public/cms/images/`, and URL `/cms/images/`.
  
  I create an Assets field named 'Hero image', not restricted to a single folder, with source 'Local storage', and default upload location 'Local storage' with path `heroes/{slug}/`.
  
  I'd expect uploads for Hero image to land in the `/public/cms/images/heroes/{slug}` folder. When I do upload an asset, this folder is created, yet the asset lands in the root `/public/cms/images` folder.
  
  Why might this be?
  
  **Tags:** assets
  
  > **Comments:**
  > **username_1**: Try using absolute paths/URLs and see if that works. You probably just have a relative path setup incorrectly somewhere.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-11-18. Score: 5 | Accepted answer
  
  This answer really belongs to username_1, as he mentioned it to me. But he doesn't really need the points, does he ;)
  
  What you want in that slot is {owner.slug}, and then the proper sub-path will ensue.
  
  The explanation is deep in the doc page at: <http://buildwithcraft.com/docs/assets-fields>
  
  To wit,
  
  > "Note that if you are creating the Assets field within a Matrix field,
  > the source element is going to be the actual Matrix block, not the
  > element that the Matrix field is being created on. So if your Matrix
  > field is attached to an entry, and you want to output the entry ID in
  > your dynamic subfolder path, you would type {owner.id} not just {id}."
  
  > **Comments:**
  > **username_1**: You get the rep fair and square. :) Didn't even think it might be in a Matrix field.  
  > **username_2**: I did rather make the assumption, didn't I...but the reason is that the only place {slug} is mentioned in this fashion is in the form for Matrix images. Really, it should say {owner.slug} there to be correct, shouldn't it?  
  > **username_0**: That's a good point for matrix fields. However I'm still having the same problem for non-matrix fields after making the file system path absolute.  
  > **username_0**: The correct subfolder is created in the filesystem, but as the root 'Local storage' location is highlighted when I open the 'Add an asset' dialog it adds it there.  If I highlight the correct folder manually I get an error where there is a double directory separator slash: 'Error uploading the file: The folder "/home/apps/test/public/cms/images/heroes//history/" does not exist.'  I've double checked and there don't seem to be any trailing slashes on the paths I've set.  
  > **username_0**: Ah, I understand now that this default upload location will only be used if the asset is dragged onto the field, or the 'Restrict uploads to a single folder?' is checked. I'm still getting the double slash error though.  
  > **username_2**: Hmm. I actually have a trailing slash on both my Asset file system path and web url. If I use {slug} in an ordinary Assets field and drag-drop an image, things work as expected, no double slash error, and the image ends up in the directory associated with the page slug. This also works if I take the trailing slash off. Maybe try this with devMode true in general.php, then send a support request from the CP with logs included as should be automatic, so username_1 can look at your circumstance?  
  > **username_2**: Another little interesting point is that the Assets dialog actually put the trailing slash back into the file system path when I saved it. So I wonder what version of Craft you are running? Latest 2.2.2601 here.  
  > **username_0**: I'm running 2.2.2601. This was a permissions issue of being unable to create the folder rather than a problem with the double slashes. Many thanks for your help on this.  
  > **username_2**: There you go, and most welcome, username_0.  
  
  ---
  
  