How to get the full path of the file from a file input [duplicate]
Possible Duplicate:
Full path from file input using jQuery
I have the following html element
<input type="file" id="upload">
If I use
$("#upload").val();
I only the file name, not the complete absolute path of the file. Can someone tell me how do get the complete path?
Solution 1:
You cannot do so - the browser will not allow this because of security concerns. Although there are workarounds, the fact is that you shouldn't count on this working. The following Stack Overflow questions are relevant here:
- full path from file input using jquery
- How to get the file path from HTML input form in Firefox 3
In addition to these, the new HTML5 specification states that browsers will need to feed a Windows compatible fakepath into the input type="file"
field, ostensibly for backward compatibility reasons.
- http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-March/018981.html
- The Mystery of c:\fakepath Unveiled
So trying to obtain the path is worse then useless in newer browsers - you'll actually get a fake one instead.