How can I add the file path to the array, for example via input type = 'file'?

  • 0
    Hello everyone!! I need an array with photo paths, how can I add them? Can this be done via input type = 'file'?
    JavaScript Nicholas Foley, Apr 7, 2019

  • 1 Answers
  • 0
    As described at https://learn.javascript.com/file :



    <img id="testImage">
    <input type="file" onchange="readFile(this)">

    <script>
    function readFile(input) {
    let reader = new FileReader();
    reader.readAsDataURL(input.files[0]);
    reader.onload = function() {
    document.getElementById('testImage').src = reader.result;
    };
    }
    </script>
    Lilly Wood

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!