Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
开发者_开发技巧 Improve this questionAnd then alert the file name?
This should suffice:
alert($('#your_input_box').val());
A file selection box is just an input box, from what I can tell. Read more from this question: jQuery: get the file name selected from <input type="file" />.
To detect if a file was selected, you can find out the length of the file input
$("#bCheck").click(function() { // bCheck is a input type button
var fileName = $("#file1").val();
if(fileName) { // returns true if the string is not empty
alert(fileName + " was selected");
} else { // no file was selected
alert("no file selected");
}
});
精彩评论