Can anyone suggest a way, or a module to truncate very long filenames which are uploaded to a Drupal 7 website? I have a client who keeps uploading files that are actually sentences and I want to limit the filename to a reasonable and certain amount of characters (say 20).

Thanks for any help on this.

1 Answer 1


You could use a presave hook and rename the file before it gets saved: https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_file_presave/7

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.