2

In Bootstrap FileStyle (http://markusslima.github.io/bootstrap-filestyle/) how can I use make it get the full path instead of only the file name ?

madth3
  • 7,275
  • 12
  • 50
  • 74
Nelson Teixeira
  • 6,297
  • 5
  • 36
  • 73

1 Answers1

3

I see that the Bootstrap FileStyle plugin start from a standard input file element.

So you can get its value by:

$("input[type=file]").val();

Demo code:

$(document).ready(function () {
    $(":file").filestyle({
        classButton: "btn btn-primary"
    });

    $("#getFileName").click(function () {
        alert($("input[type=file]").val());
    });
});

Demo: http://jsfiddle.net/IrvinDominin/8CpnH/

EDIT

If you want to get the full path name you'll face a "problem" not related to the plugin, but to browser security reasons.

You can check some related and deep questions on SO like How to get full path of selected file on change of <input type=‘file’> using javascript, jquery-ajax?

Community
  • 1
  • 1
Irvin Dominin
  • 30,819
  • 9
  • 77
  • 111