Get File Name from File Upload

HI guys,
I run into a problem. I have a input of type file and I'd like to grab the file name of the uploaded file and assign it to a variable, but I don't seem to be able to do that.
I'm hiding hte input with opacity 0 and hiding it behind a span which is styled to look like a button, common techinque as we all know, that shouldn't have any inpact on what I'm doing whatsoever. Anyway, here is the script (it's part of a Spring application by the way), here is the fll code:

So I click the pseudo button, the file system window opens, I select the file and press OK and that's when I want to get that file name.
I tried in a few different ways, but I either get an error or just undefined, and I don't quite get the reason why I get undefined, whether it's a matter of timining or just a stupid error I'm making.
This, which should work, returns undefined:+"var fileName = $('this').val();"
This comes back with an error, saying "TypeError: $(...).prop(...) is undefined"+"var fileName = $('this').prop('files')['name'];"
This returns an object but I'm not sure if it's helpful or not:+"var fileName = $('this').attr('src', e.target.result);"

well, well, lo and behold...It seems like I cracked it in the end, but alas I have no idea why. So, this is what I've done, something very simple in fact. As you can see I used $('this'), as I would normally do:+"var fileName = $('this').val();"
except that it doesn't need the darn quotes around it,+"var fileName = $(this).val();"
too many quotes in that script, I got confused.