user796443
user796443

Reputation:

styling input type:file inconsistency - FilePath between IE and Firefox (jquery)

I'm trying to style input type:file.

Problem I've encountered is that in Firefox I don't see file path, while in IE it gives me full file path.

Any way to make these two browsers behave same way?

http://jsfiddle.net/sandrodz/yEG4w/

Thanks.

Upvotes: 2

Views: 329

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337637

No, this is a security feature of the browsers whereby the only information you get is the filename, and the file itself.

Strictly speaking, IE should not give you the full file path of the client machine as it can be used maliciously.

To get just the filename from IE, try this:

var filePath = $("#fileInput").val().split("\\");
var fileName = filePath[filePath.length -1];

Example fiddle

Upvotes: 2

Related Questions