<input type="file" name="images[]" id="img" class="nameForm" multiple="true" accept="image/*,image/jpeg"> <iframe name="uploadImg" src="#" id="frameImg"></iframe> 

Contents of the frame:

 <input type="file" name="images[]" id="imgUpl" class="nameForm" multiple="true" accept="image/*,image/jpeg"> 

As I try to put data there:

 var img = document.getElementById('img').value; $('#imgUpl').attr('value', img.val); alert(img.val); 

When an alert issues anfadend.

How can I implement so that the values ​​of one input file can be transferred to another input file? Or is there just reading?

    1 answer 1

    For security reasons, the value attribute of input file works only in read mode.

    Then undefined crashes due to the fact that from somewhere you take the property val from a string record.

    It should be like this:

     var img = document.getElementById('img').value; $('#imgUpl').attr('value', img); alert(img); 

    And then we communicate with iframe as follows:

     var iframeDoc = iframe.contentWindow.document; 
    • Thanks It works. Is it possible to shove these values ​​into #imgUpl? The fact that I have is not working. - rimlin
    • @rimlin is said to you, value at input file is read-only :-) - lampa