I have client who is uploading files with lots of naming issues; Spaces, dots, parenthesis, and other characters in the filenames.
Is it possible to strip out the special characters, automatically, upon upload?
Thank you in advance.
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It only takes a minute to sign up.
Sign up to join this communityI have client who is uploading files with lots of naming issues; Spaces, dots, parenthesis, and other characters in the filenames.
Is it possible to strip out the special characters, automatically, upon upload?
Thank you in advance.
Your best bet would be to make an extension that hits this hook:
http://docs.pixelandtonic.com/assets/developers/hooks/upload_file.html
And renames the file after upload. I would check the File helper to see if it can rename files:
https://ellislab.com/codeigniter/user-guide/helpers/file_helper.html
If not you'll have to do it in pure PHP:
http://php.net/manual/en/function.rename.php
Be warned; after rename the file, you'll need to use the database class to update all Assets rows that have the file name of your original file, and update them with the new file name. Also probably the EE files table.
Actually, at this point, you could honestly just hack the Assets core. I highly do not recommend doing that, but it would work for now. just regex out anything that isn't alpah-numeric.