I'm trying to remove any character except 0-9 a-z A-Z....
var file_name = file.name;
file_name = file_name.replace(/[^A-Z0-9\._\-]/i, '');
any obvious reason the above isn't working?
You need to specify the global-flag on your regular expression. Otherwise, only the first occurrence will be replaced:
file_name = file_name.replace(/[^A-Z0-9\._\-]/gi, '');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With