Browse Source

Merge pull request #632 from klcockerill/master

Find correct filename in IE9
Kartik Visweswaran 9 years ago
parent
commit
8dc9251f6e
1 changed files with 8 additions and 1 deletions
  1. 8 1
      js/fileinput.js

+ 8 - 1
js/fileinput.js

@@ -1854,9 +1854,16 @@
             readFile(0);
             self._updateFileDetails(numFiles, false);
         },
+        _findFileName: function (filePath) {
+            var sepIndex = filePath.lastIndexOf('/');
+            if (sepIndex == -1) {
+                sepIndex = filePath.lastIndexOf('\\');
+            }
+            return filePath.split(filePath.substring(sepIndex, sepIndex + 1)).pop();
+        },
         _updateFileDetails: function (numFiles) {
             var self = this, $el = self.$element, fileStack = self.getFileStack(),
-                name = ($el[0].files[0] && $el[0].files[0].name) || (fileStack.length && fileStack[0].name) || '',
+                name = (isIE(9) && self._findFileName($el.val())) || ($el[0].files[0] && $el[0].files[0].name) || (fileStack.length && fileStack[0].name) || '',
                 label = self.slug(name), n = self.isUploadable ? fileStack.length : numFiles,
                 nFiles = previewCache.count(self.id) + n, log = n > 1 ? self._getMsgSelected(nFiles) : label;
             if (self.isError) {