0

I am trying to upload image using input type file , it is reflecting first uploaded image after second uploading

<div class="uploadimg">
    <input type="file">
   <img src="img.png">
</div>

$("document").ready(function(e) {
$(".uploadimg > input").click(function(){
    var browse = $(".uploadimg > input").val();
    $(this).change(function(){
        $(".uploadimg > img").attr("src","images/"+browse); 
    });
}); });
  • What the question? – X.Creates Feb 22 '17 at 06:02
  • .click -> .on("change", ...), remove the second change() –  Feb 22 '17 at 06:09
  • file input does contain a File object. If you want to display it, use `URL.createObjectURL(fileInput.files[0])` as the url. You can't set it to an absolute path pointing to the user machine for obvious security reasons. – Kaiido Feb 22 '17 at 06:09
  • Possible duplicate of [Preview an image before it is uploaded](http://stackoverflow.com/questions/4459379/preview-an-image-before-it-is-uploaded) – Kaiido Feb 22 '17 at 06:13

0 Answers0