0

For a content type "TEST" which has a field "upload file", I want the file path before saving the node. hook_node_presave can be used to do anything before saving the node. I want to rename the file before it get saved into database.

but my file is getting saved first into the database.

How to do rename a file before it gets saved into database in a custom module.

1

Check out hook_file_presave() function.

You might have to additionally rename/move the file after it has been uploaded.

See also this thread and check the File (Field) Paths module as it might have already the functionality you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.