I'm using:


to display my file upload form in Channel Forms to allow the user to upload a file.

I want to be able to change the filename and append their user ID to it but can't figure out how...the EE documentation doesn't provide any clues either.

Any thoughts?

Thanks, Dan

1 Answer 1


You'll need to write an extension which uses the file_after_save hook. This hook passes you the $file_id and an array of info about the file called $data. Using this info you should be able update the file name doing something like this in your extension:

function file_after_save($file_id, $data)
    $parts = pathinfo($data['file_name']);
    $new_file_name =
        '_foobar_'. // whatever you want to add to the filename

    ee()->filemanager->rename_file($file_id, $new_file_name, true);
  • 1
    Thanks for the response...I'll try the extension route and see if I have any luck...was hoping for it to be a simple solution since I've never written an extension before. Will mark as the answer as soon as I try it and have some luck. Thanks again!
    – DanH
    Jan 18, 2015 at 21:39
  • I'm wondering if you ever managed to write this extension, because I'm very interested in achieving the same thing...
    – Tim
    Oct 7, 2020 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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