It would be great if I could specify a particular "File path" for each new field as it does in the imagefield module.
i.e. Optional subdirectory within the "files" directory where images files will be stored. Do not include trailing slash.

I'll work on this when I get a chance as well... if there are a lot of others requesting this I will work faster. Unless there are already plans by the maintainer?

Comments

sirkitree’s picture

Status: Active » Needs review
StatusFileSize
new2.21 KB

I've implemented this and here is the patch.

sirkitree’s picture

Ok, got a little ahead of myself there, just realized that I've only got a piece of it right now: the directory gets created, but it is not uploading the file to that path. You can change the last post to (code needs work).

sirkitree’s picture

Status: Needs review » Needs work
StatusFileSize
new3.91 KB

Ok, here is another revision, still not quite working, but I needed to post so that i know where the heck I am on Monday... this version inserts in the $field['widget']['file_path'] in a few places i noticed needed it, but still not working completly. Any direction you can give over the weekend would be appreciated.

sirkitree’s picture

Status: Needs work » Needs review
StatusFileSize
new4.68 KB

Ok, this is finally working. There was one last place that needed the $field['widget']['file_path'] and now it works. Please review and post any feedback.

sirkitree’s picture

so i just saw that there was a similar issue in HEAD that one-ups this by implementing tokens as well with the filepath... guess i should look a little harder through the issues next time...

ray007’s picture

Is anything holding up a release with this feature?

jpetso’s picture

Hm... filefield's HEAD version contains all of the patch except for the parts where file_create_path() is replaced with file_create_path($field['widget']['file_path'])). Is this still necessary? If so, why is this needed?

sirkitree’s picture

This patch isn't still necessary, but that line, file_create_path($field['widget']['file_path'])) definitely is. Without it, I don't think the file will be created in the designated spot. Not sure why it's not in there.

jpetso’s picture

Status: Needs review » Fixed

Ok, thanks for the patch and the additional info. I added the remaining $field['widget']['file_path'] occurrences, so everything should work correctly now. (Here's the commit.) Storing the files also worked before that, because those file_create_path() calls that were still there were only responsible for creating URLs. In consequence, URLs previews for files that are currently being uploaded are fixed now.

Anonymous’s picture

Status: Fixed » Closed (fixed)