Can't get value of input type=“file”?

后端 未结 8 2042
谎友^
谎友^ 2020-11-27 16:48

I have a

When I\'m using: alert($(\"#uploadPicture\").val());

It ale

相关标签:
8条回答
  • 2020-11-27 17:13

    You can get it by using document.getElementById();

    var fileVal=document.getElementById("some Id");
    alert(fileVal.value);
    

    will give the value of file,but it gives with fakepath as follows

    c:\fakepath\filename
    
    0 讨论(0)
  • 2020-11-27 17:14

    You can read it, but you can't set it. value="123" will be ignored, so it won't have a value until you click on it and pick a file.

    Even then, the value will likely be mangled with something like c:\fakepath\ to keep the details of the user's filesystem private.

    0 讨论(0)
提交回复
热议问题