Skip to content

Instantly share code, notes, and snippets.

@nyl2k8
Created October 22, 2019 11:04
Show Gist options
  • Save nyl2k8/0508fe3fd7f9cc8dc00a5d6bacbce4d5 to your computer and use it in GitHub Desktop.
Save nyl2k8/0508fe3fd7f9cc8dc00a5d6bacbce4d5 to your computer and use it in GitHub Desktop.

Revisions

  1. nyl2k8 created this gist Oct 22, 2019.
    24 changes: 24 additions & 0 deletions index.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    <form action="/controller.php" method="post" enctype="multipart/form-data">
    <input type="file" id="imgInput" name="file" />
    <img src="/assets/default_empty.png" id="upImage" src="#" alt="Upload Image" />
    </form>

    <script type="text/javascript">
    function readURL(input) {
    if (input.files && input.files[0]) {
    var reader = new FileReader();
    reader.onload = function(e) {
    $('#upImage').attr('src', e.target.result);
    }
    reader.readAsDataURL(input.files[0]);
    }
    }
    $("#imgInput").change(function() {
    readURL(this);
    });
    </script>