javascript - How to change value of input type file in Jquery -


this question has answer here:

i have got html code

<img src="../img/1.jpg" class="img"> <img src="../img/2.jpg" class="img"> <img src="../img/3.jpg" class="img"> <img src="../img/4.jpg" class="img"> <input type="file" name="file" id="file" onchange="bgchange(this)" > 

and jquery

$(".img").click(function(){                         var srcat=$(this).attr('src');                         $("#file").attr('value',srcat);                         alert($("#file").val());                 }); 

but not changing value stays empty.is there anyway can change that?

you not allowed change value of input[type="file'] via script. security mechanism. if possible, websites steal file in hard drive. not cool.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

post - imageshack API cURL -

dataset - MPAndroidchart returning no chart Data available -