I have the following line of code here which makes a user text appear upon clicking the send button (to simulate chat messages being sent)
<script>
$('#subbut').click(function(){
var user_msg = $("#user_msg").val();
$("#msg").append('<p>User says:'+user_msg+'</p>');
</script>
<body>
<div id="msg"></div>
<input type="text" name="user_msg" id="user_msg">
<input type="submit" value="Submit" id="subbut">
</body>
However I wish to do this for input of images too.
<body>
<div id="msg"></div>
<input type="file" name="newImage" id="upload-photo">
<input type="submit" value="Submit" id="subbut">
</body>
How do you access the image and append it (to display the image) to the #msg div when the #subbut button is clicked? I've looked at something similar here Preview an image before it is uploaded but I can't seem to adapt it.