开发者

How to assign file input value from another one with Jquery?

开发者 https://www.devze.com 2023-04-05 20:38 出处:网络
I have some elements like these: <input type=\"file\" name=\"fake\"> <input type=\"file\" name=\"real\" style=\"display:hidden;\">

I have some elements like these:

<input type="file" name="fake">

<input type="file" name="real" style="display:hidden;">

<a href="javascript:void(0)"  onclick="addToList开发者_运维知识库()">

<input type="submit" name="submit" value="Submit">

My question is : is it possible to assign the value of the "fake" input to "real" input by using jquery? So that when I hit Submit button, the "real" file input will be uploaded.

addToList = function(){
    //what should I do here to assign the "real" file input value
}


My understanding is that generally you won't be able to assign a file to a file input element-- this is a security restriction so that you can't programmatically grab random files off of someone's disk.

I'm not sure what you are trying to accomplish, but there is some newer HTML5 capabilities that might help documented here.

0

精彩评论

暂无评论...
验证码 换一张
取 消