I am trying to delete any character except 0-9 az AZ ....
var file_name = file.name; file_name = file_name.replace(/[^A-Z0-9\._\-]/i, '');
is there any obvious reason why the above is not working?
You need to specify a global flag in your regular expression. Otherwise, only the first occurrence will be replaced:
file_name = file_name.replace(/[^A-Z0-9\._\-]/gi, '');
Give Regexr a go. Hover over the checkboxes in the text box at the top to see the options you have. Look at the bottom panel to see the generated regular expression.