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?
Click the Start button and then click Computer, click to open the location of the desired file, hold down the Shift key and right-click the file. Copy As Path: Click this option to paste the full file path into a document. Properties: Click this option to immediately view the full file path (location).
If you go to Internet Explorer; Tools; Internet Option; Security; Custom; find the "Include local directory path when uploading files to a server" (it is quite a ways down) and click on "Enable" You may have to restart your computer, but this works & eliminates that "fakepath" that inhibits the upload file path.
To get current file's full path, you can use the os. path. abspath function. If you want only the directory path, you can call os.
The value property returns the path or the name of the file selected with the <input type="file"> element. This property returns the name of the selected file with a fake path in IE, Google Chrome, and Opera, and the name of the selected file in Firefox and Safari.
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:
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.
So trying to obtain the path is worse then useless in newer browsers - you'll actually get a fake one instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With