0

I have an div on one side and an input type file on the other side. I wanted on click of a button, to copy the content of the div (which is an image) into to the input file. So I tried.

$(document).ready(function(){
  $('#mbtn').click(function(){
    $('#mfile').attr('value',$('#mdiv').html());
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" id="mfile">
<div id="mdiv"></div>
<button id="mbtn" type="button">Clikck</button>
Shiladitya
  • 12,003
  • 15
  • 25
  • 38
  • so you want to copy an image inside a input type "file"? – derloopkat Nov 23 '17 at 00:37
  • i did something like this way back but was a little different as it included uploading file with the dropzone.js and selenium web drivers, see here if you could use it https://stackoverflow.com/questions/27785721/dropzone-js-how-to-upload-file-using-selenium-php-webdrivers – Muhammad Omer Aslam Nov 23 '17 at 01:04
  • yes bro, I want on click on the button, the input file "mfile" must be filled with an image. – Safari.Mupe Nov 24 '17 at 07:09

0 Answers0