Line | |
---|
1 | $(document) |
---|
2 | .on('change', '.btn-file :file', function() { |
---|
3 | var input = $(this), |
---|
4 | numFiles = input.get(0).files ? input.get(0).files.length : 1, |
---|
5 | label = input.val().replace(/\\/g, '/').replace(/.*\//, ''); |
---|
6 | input.trigger('fileselect', [numFiles, label]); |
---|
7 | }); |
---|
8 | |
---|
9 | $(document).ready( function() { |
---|
10 | $('.btn-file :file').on('fileselect', function(event, numFiles, label) { |
---|
11 | |
---|
12 | var input = $(this).parents('.input-group').find(':text'), |
---|
13 | log = numFiles > 1 ? numFiles + ' files selected' : label; |
---|
14 | |
---|
15 | if( input.length ) { |
---|
16 | input.val(log); |
---|
17 | } else { |
---|
18 | if( log ) alert(log); |
---|
19 | } |
---|
20 | }); |
---|
21 | }); |
---|
Note: See
TracBrowser for help on using the repository browser.