0

In my code below i am uploading a file in the input file below and i am trying to assign that image that i upload to a var called addimg using val(). But when i add it in the append function below it shows C:\fakepath\ (in the elements tab in dev tools google chrome) instead of the actual image src. How can i get the image source to work properly?

JS

    addimg = $('.addimg').val();
    $('table').append('<tr><td>'+date+'</td><td><img src="'+addimg+'"/></td> 
    <td>'+addname+'</td><td>'+addqty+'</td><td>'+adddescript+'</td><td>'+addcat+'</td> 
    <td>'+addprice+'</td></tr>');

HTML

<input class="addimg" type="file" name="Choose Image">

<table>

<table>
Uriel Bitton
  • 252
  • 6
  • 18
  • Side note; technically, your not uploading a file. You're just referencing one locally. – Taplar Nov 27 '19 at 22:10
  • And taking a glance at `e.target.files[0]`, I'm not sure that the browser offers the full path to javascript. – Taplar Nov 27 '19 at 22:14
  • ok so is there a workaround to this? how can i get the image uploaded to a var and display that img in my html with jquery? – Uriel Bitton Nov 27 '19 at 22:25

0 Answers0