Fixing c:\fakepath in filestyle jquery plugin

Mar 26, 2010 javascript jquery
This post is more than 18 months old. Since technology changes too rapidly, this content may be out of date (but that's not always the case). Please remember to verify any technical or programming information with 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());
});

After

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