Have you tried to manipulate the string that is returned by the value attribute of a file upload input (<input type="file" />) under Internet Explorer 8? Did you get the strange c:\fakepath string? Relax - there is nothing wrong with your code, and although this is quite confusing, it has its justifiable reasons. Here is a screenshot of a file input control manipulated with JavaScript:

According to the specifications of HTML5, a file upload control should not reveal the real local path to the file you have selected, if you manipulate its value string with JavaScript. Instead, the string that is returned by the script, which handles the file information is c:\fakepath.
This requirement is already implemented in Internet Explorer 8 – the real path to the file will be shown only if the page that contains the control is added to the trusted sites collection of the browser.
Below is some code to play with. Notice that this will not work on localhost pages. The page should be uploaded on a production server.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head>
<title>Testing the FakePath String</title>
</head>
<body>
<form id="Form1" action="" method="post">
<input type="file" /><input type="button" onclick="alert(this.previousSibling.value);" value="select file and press the button" />
</form>
</body>
</html>
More Cool Stuff
- Ribbonbar Web UI Component
- HTML5 Resume Generator and Onepager Website
- Acid.JS Web.UI Library
- CSS3 Treeview. No JavaScript.
- Selecting only the first element occurence out of siblings with the same class name with CSS3
- How to Style Select Boxes with CSS3
- CSS3 Element Reflections
- CSS3 iPhone Toggle Buttons
- CSS3 Gaussian Blur Effect
- Fancy CSS3 Tooltips Without JavaScript
- CSS3 Background Image Cropping
[...] Mystery of c:fakepath Unveiled « Martin Ivanov] http://acidmartin.wordpress.com/2009/06/09/the-mystery-of-cfakepath-unveiled/ Verwandte Beiträge:Entfernungsstatus Gerade entdeckte ich auf Windows Server 2008 zwei [...]
[...] This article has a bit more information on the subject. Apparently if you add the site in question to the “Trusted sites” list in Internet Explorer it will return the file path. But of course you can’t expect users to do that. [...]
[...] This article has a bit more information on the subject. Apparently if you add the site in question to the “Trusted sites” list in Internet Explorer it will return the file path. But of course you can’t expect users to do that. [...]
[...] This article has a bit more information on the subject. Apparently if you add the site in question to the “Trusted sites” list in Internet Explorer it will return the file path. But of course you can’t expect users to do that. [...]
[...] 如果还是不理解的话,请看这篇文章《揭露 c:fakepath 的秘密》。 [...]
[...] This article has a bit more information on the subject. Apparently if you add the site in question to the “Trusted sites” list in Internet Explorer it will return the file path. But of course you can’t expect users to do that. [...]
[...] The Mystery of c:fakepath Unveiled June 2009 6 comments and 3 Likes on WordPress.com 4 [...]
[...] of them were prepending "C:fakepath" to the file name. WTF?!After doing some research, I found this blog post, which explained:According to the specifications of HTML5, a file upload control should not reveal [...]
Q: why the hell did a ‘C:\fakepath’ made it into a STANDARD???
Why not simply leave it empty, no path, just the plain file name? This looks totally weird on any none-windows system.
Or is anybody at microsoft concerned about at least leaving some traces for the time after windows has become obsolete???
[...] picture to a website in Internet Exlorer, namely Craiglist as one of them. After a bit of research, the mystery was unveiled. According to the specifications of HTML5, a file upload control should not reveal the real local [...]
ah, jesus, i was searching my whole project code, like, this MUST be from early debugging or something. bah– and it worked in Firefox the whole time so I had no suspicions.