0

I have several file inputs and I need to append uploaded images in a DOM element.

Here is my HTML:

<input type="file" name="images[]" id="file-1" class="file">
<input type="file" name="images[]" id="file-2" class="file">
<input type="file" name="images[]" id="file-3" class="file">
<div id="display-images"></div>

Here is my jQuery:

$('.file').change(function(){
    var input = $(this);
    var image = input.prop('files')[0];
    $('#display-images').append('<img src="???"');
});

What should I write in src attribute to display uploaded file?

eylay
  • 1,543
  • 3
  • 19
  • 43
  • There is a big difference between viewing an uploaded file (ie. after the upload is complete read the file in situ on your server) and reading the file that was selected on the client machine (ie. read the file data in the `input` control). Which exactly are you trying to do? – Rory McCrossan Sep 13 '19 at 12:25
  • i need to display file that was selected on the client machine @RoryMcCrossan – eylay Sep 13 '19 at 12:27
  • In which case note that this has nothing to do with uploading a file. Please see the duplicate I've marked for the solution – Rory McCrossan Sep 13 '19 at 12:30

0 Answers0