I’m trying to alert the filename from a upload input.
Here’s my fiddle
It works, but there’s the “C:Fakepath…” something like that.
I just want the filename, without the Fake path. I tried using the split function, but I’m not sure why it’s not working.
Example html:
<html>
<head>
<title>Test Page</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<input type="file" id="tester" />
</body>
</html>
Example script:
$(function() {
var bogus;
var triple;
$('#tester').change(function() {
triple = $('#tester').val();
bogus = triple.split(/[\s/]+/);
alert(bogus[bogus.length - 1]);
});
});
Any idea?
Thank you!
You can just escape the slash:
Updated fiddle: http://jsfiddle.net/johnkoer/xwdct/3/