I have a site under "sites/default" and files folder in "sites/default/files".

When I upload an image, an extra "sites/default" directory is created under "sites/default/files" which eventually looks like this - "sites/default/files/sites/default".

The directory is empty and everything seems to work fine.

I looked in the code and debugged function filefield_paths_file_move a little bit. When I do echo $path = file_create_path(implode($dirs, '/')); I get the following results:

sites/default/files/sites
sites/default/files/sites/default
sites/default/files

It seems that _filefield_paths_check_directory() function creates these directories along the way.

Comments

thtas’s picture

subscribing. I have a similar issue.

Starminder’s picture

subscribe

Deciphered’s picture

Status: Active » Postponed (maintainer needs more info)

Strange, there is a specific function around that section that is there to strip out that path in the case that a user has entered it in the filepath setting of the file incorrectly.

Can you tell me what your fields FileField Paths settings are?
And also what have you got set in 'File system path' in admin/settings/file-system?

Cheers,
Deciphered.

maijs’s picture

Deciphered, I have pretty standard setup. FileField Path settings are:

1. File name in field settings: [nid]-[filefield-onlyname-original].[filefield-extension-original] ([nid] is replaced with Node ID by Token module);
2. File system path: sites/default/files, temporary directory: /tmp, public method.

Changing the settings, I discovered than extra sites/default directory is being created in sites/default/files only when Token pattern is placed in field "File name" field. If I leave default [filefield-onlyname-original].[filefield-extension-original] filename then directory is not created.

Deciphered’s picture

What have you got in File Path?

maijs’s picture

File Path is empty. Here is the complete spec:

1. File Path: empty
2. File path cleanup settings: nothing checked
3. File Name: [nid]-[filefield-onlyname-original].[filefield-extension-original]
4. File name cleanup settings: "Convert to lower case" and "Transliterate" checked
5. Retroactive update: not checked
6. Active updating: not checked

In Site configuration > File system > File system path I have standard "sites/default/files"

Deciphered’s picture

Status: Postponed (maintainer needs more info) » Active
Issue tags: +FileField Paths 2.x

Thanks maijs,

I suspect the issue is related to the empty filepath, can you confirm that that is the case?
As strange as it is, it's very rare for anyone to use this module without a filepath, so for this to be the cause of the reason isn't as surprising as it should be.

Will definitely be fixed in the upcoming 2.x release.

Cheers,
Deciphered.

maijs’s picture

Deciphered,

Correct, if file path is set then sites/default folder is not mistakenly created.

I use FileField Paths to attach node id to the filename, I do not manage files in directories.

Deciphered’s picture

Maijs,

That is a perfectly acceptable use case, and should definitely work.
As a short-term work-around, try putting a single forward-slash ('/') in the file path field.

It's untested, but theoretically it should do the job.

Cheers,
Deciphered.

Deciphered’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

No longer supporting Drupal 6 issues for this module.