In HTML
<input type= "File" id= "ImportFile"/> <input type=
"button" onclick= "Upload ()"/>
<script>
function upload () {
var filename = document.getElementById ("ImportFile"). Value;
The filename at this time is not the value
alert (filename) in the ImportFile box;
}
</script>
As the above code, the File Upload dialog box to select files, if you choose the "d:\\temp\file\test.txt" file, alert (filename) is "c:\\fakepath\test.txt" This is why? I want to get the original file path and file name, what should I do? Thank you all for the first.
Txlfillin= "isnotnull" title= "link Picture" >
<script type= "text/javascript" >
function Setblogrollimagename (basicfile) {
document.getElementById ("Blogrollimagename"). Value=basicfile.value;
</script>
Input when the onchange= "Setblogrollimagename (This)" Plus, and then this section of JS added to the page can!
Thank doop1120 for your reply.
I did what you said, but the result was the same. If you choose "d:\\temp\file\test.txt", document.getElementById ("Blogrollimagename"). Value=basicfile.value;
The value obtained in this way is still document.getElementById ("Blogrollimagename"). value=C:\\fakepath\test.txt, not what I want d:\\ Temp\file\test.txt
The reason for the d:\\temp\file\ is the Internet Explorer security settings problem
Steps to resolve this issue:
Open IE browser-->internet option--> security--> Custom Level--> other--> enable "show file directory path when uploading files to server"
Be sure to run again
The above JS access to upload files of the absolute path to achieve the method is small to share all the content of everyone, hope to give you a reference, but also hope that we support the cloud habitat community.