jQuery, Get filename without the extension and then replace string
Ok, to only get the filename I used this:
var output = filename1.substr(0, filename1.lastIndexOf('.')) || filename1;
To do the replacement of characters I used this:
output = output.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '-');
There is a better way to get filename and extension
fileName = 'upload.png';
If you need only filename
filename.split('.').shift();
If you need only extension
filename.split('.').pop();