Skip to content

Fixing c:\fakepath in filestyle jquery plugin

Mar 26, 2010 1 min read #javascript #jquery

This post is more than 18 months old. Technology changes quickly, so some of this content may be out of date (but that's not always the case). Please verify any technical or programming information against the current release.

The other day I ran across an issue with the FileStyle jquery plugin. Whenever a new file was chosen, windows and Internet Explorer would put c:\fakepath\ before the filename. Turns out its not FileStyle’s issue - but a security feature of Internet Explorer.

As a quick fix, however, I made the following changes to FileStyle:

Before

$(self).bind("change", function() {
  filename.val($(self).val());
});
javascript

After

$(self).bind("change", function() {
  var s = $(self).val().replace(/(c:\\)*fakepath/i, '');
  filename.val(s);
});
javascript