By phl3tch on
Can anyone suggest a way to change the name of a file uploaded via CCK/filefield based on a user-submitted name? Clearly it would be simplest if they just changed the name before uploading the file, but for whatever reason I have a client that is insisting on this capability. Ideally I'd like another field in my custom content type with the new filename, which would be applied on uploading.
Comments
nudge...?
nudge...?
any answers?
hello
were you able to find a solution for this? i have also been looking for a similair feature for my website.
i agree that a field in the settings should possibly help solve this issue.
any other ideas?
arvi
got a fix finally --- works for me !
i changed the insert value for the file table from $file[filename] to $file['description']
to
If you now upload the file and change the description of the file it lists it as the text specified
Cool. Wish I could remember
Cool. Wish I could remember why I was trying to do this though...
Description
I found the location for setting the link to the file in filefield_formatter.inc
return '
';
however, i am unclear how to get at the description of the file to replace 'filename'.... any help for a new Drupal 6 user?
Got the Hack
So you change $file['filename'] to $file['data']['description']
Use token
There is the Token module that seems to be working when it comes to renaming files paths. I was looking at the filefield_file_insert function and found this piece of code in it ;)
So I guess in the field settings you can just use the accepted tokens and they will be changed at the saving step.