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>