From what I've ready you should be able to use the 'value' property of a file input field to get the currently set path of that field. But when I do this:
$('#fileinput').value()
I get 'undefined'. The ID of the field is set to "fileinput" I'm sure. Does anyone have any thoughts on why this might not be working for me?
And by the way, this works:
var d = document.getElementById('AttachmentFile'); alert(d.value);
So I guess this has something to do with the way jQuery works that I don't fully understand.
Thanks!
To get the textbox value, you can use the jQuery val() function. For example, $('input:textbox'). val() – Get textbox value.
The only way to set the value of a file input is by the user to select a file. This is done for security reasons. Otherwise you would be able to create a JavaScript that automatically uploads a specific file from the client's computer.
var fullPath = $('#fileUpload1'). val();
You need to use val rather than value.
$("#fileinput").val();
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