0

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.

0

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.

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.