The absolute path realization method of getting uploaded files by js _javascript skill

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.