In html

 <input type="file" />
  <input type="button" onclick="upload ()" />
function upload () {
  var filename=document.getelementbyid ("importfile"). value;
  //filename is not the value in the importfile box
  alert (filename);
<input type="file" name="blogrollimage" onchange="setblogrollimagename (this)" txlfillin="isnotnull">
<script type="text/javascript">
function setblogrollimagename (basicfile) {
document.getelementbyid ("blogrollimagename"). value=basicfile.value;

When inputting, add onchange="setblogrollimagename (this)", and then add this js to the page!

Thanks doop1120 for the reply.

I did as you said,However, the result is still the same.If you select "d:\\ temp \ file \ test.txt", document.getelementbyid ("blogrollimagename"). Value=basicfile.value;

The value obtained this way is still document.getelementbyid ("blogrollimagename"). Value=c:\\ fakepath \ test.txt, not theI wantd:\\ temp \ file \ test.txt

The reason d:\\ temp \ file \ appears is because of the security settings of Internet Explorer

Steps to resolve this issue:

Open ie browser->internet options->security->custom level->other->"Show file directory path when uploading files to server" enabled

Re-run after confirming

  • Previous AngularJS basic ng-keydown directive simple example
  • Next AngularJS basic ng-keyup directive simple example