I'm trying to automatically add prefixes to uploaded file names so they can later be processed by non-drupal scripts. I want to do that while the user is uploading files during creation/editing of a node.
To do that I am using
hook_file_validate($field) where I check if the file is correct and then using
$field->destination I define a new file name.
Surprisingly my issue lies in getting context to generate the proper file name (
nid of the node,
hook_file_validate is triggered before
hook_form_alter . Whene it is triggered I have no access to any data that would tell me where am I.
So far I have tried:
while defined (not a typo) when the whole form is loaded, it is undefined when the file field of the form is reloaded
again - undefined
arg(0); arg(1); arg(2);
file ajax field_quest_file
which is not very usefull
I can access
uid but it is not enough for me to create unique file names.