Image preview


    [file fileuploader filetypes:jpg id:uploader]
    <div id="preview"></div>
    <script>
    var uploader = document.getElementById('uploader');
    uploader.addEventListener('change', function(event) {
      var binaryData = [];
      binaryData.push(document.getElementById('uploader').files);
      if (binaryData[0][0]) {
        var img = document.createElement('img');
        img.src = window.URL.createObjectURL(binaryData[0][0]);
        document.getElementById('preview').innerHTML = '';  
        document.getElementById('preview').appendChild(img);
      }
    });
    var wpcf7Elm = document.querySelector( '.wpcf7' );
    wpcf7Elm.addEventListener( 'wpcf7submit', function( event ) {
      document.getElementById('preview').innerHTML = '';  
    }, false );
    </script>
    [submit "Submit"]

    Post navigation

    You might be interested in...

    No comments yet, be the first!

    Comments

    Your email address will not be published. Required fields are marked *