hi

Sorry if this is a wrong place, but I think my problem is related to your module.
I have token and filefield modules enabled.

When I'm creating new field (File) I can use [uid] token in file path: profile_video/[uid] in my case.

So.... I'm trying to upload new file - it says: creating profile_video folder, creating profile_video folder/[uid] folder
BUT... file uploaded into files/ folder instead of files/profile_video/id

If I'm trying to create another node (same type) under the same user - it works correctly and uploading file in right place.

So... problem seems exists when folder (specified in field settings) not exists.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drupalprojects’s picture

Title: Token integration a bit buggy » Uploading to files/subfolder leads to files/ instead files/subfolder
Status: Active » Needs review
FileSize
2 KB

ok. I've changed issue title cuz this is not related to token. I don't have much time right now to explain what was causing this bug, but I've prepared a patch. Test it and let me know what you think. Thanks

drupalprojects’s picture

FileSize
2.58 KB

Opps, forgot to add checking for token_replace in above patch.
Updating....

jpetso’s picture

From a quick look, this looks like it might be correct. Please give me a bit of time still until I'm done with the Drupal 6 port, then I'll get to your patch. Thanks for your help!

dopry’s picture

Status: Needs review » Needs work

The error message seems incorrect... The file was successfully uploaded, but the destination directory could not be created, so the file could not be saved...

quicksketch’s picture

Version: 5.x-2.3 » 5.x-2.4

I confirmed this is still a problem in the 2.4 release. I'd like to revise this patch so that it doesn't need to have several nested "x ? y : z" conditionals.

abhaga’s picture

Hi,

I have also run in to the same issue both with ImageField and Filefield. As per my understanding the problem in the in the filefield_file_insert and imagefield_file_insert functions. Basically the filepath for uploading the file is created before nonexistent directories in the path are created with a call to filefield_check_directory. As a result, directories are created but the files still go to files directory.

The problem can be reproduced by trying to upload a file into a path with at least last 2 directories on the path nonexistent.

A patch against 5.x-2.4 is attached which corrects this issue. Imagefield patch is similar and I will post it there. Have been using this for few months now and seems fine.

Regards,
Abhaya

abhaga’s picture

Status: Needs work » Needs review
quicksketch’s picture

Status: Needs review » Fixed
FileSize
2.37 KB

Thanks abhaga, committed. Just some code style fixes in the attached patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tanma’s picture

Hi there
In searching, this seems the best thread for this problem.

Using file field 6.x-3.9,

The problem I'm experiencing is similar in that when the file path (in my case photoalbum/[user]) doesn't exist, the images are saved in files/ folder.

My problem is different in that the file path photoalbum/[user] folder is never created. Whether the first, second or third node. Only if I manually create the folder will the images be saved in the correct folder.

Does anyone have any ideas on why this is happening? I've checked the folder permissions of the files/ folder. I haven't worked out how to implement a patch but not even sure this one (#8) would help in my case. Any help would be appreciated (seems a simple problem but can't seem to fix it).

Tan