Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gravity form preview of image upload

I have made a contact form using "Gravity Form", in which I used image uploader. Now I want to display preview of image to user which is uploading. Is there anyway to achieve this?

like image 423
Mohammad Tasneem Faizyab Avatar asked Jun 17 '16 11:06

Mohammad Tasneem Faizyab


1 Answers

Sorry, Late Answer

<script>

jQuery('#imgview').hide();  

function readURL(input) {

    if (input.files && input.files[0]) {
        var reader = new FileReader();
        jQuery('#imgview').show();
        reader.onload = function (e) {
            jQuery('#imgview>img').attr('src', e.target.result);
        }

        reader.readAsDataURL(input.files[0]);
    }
}

// your File input id "#input_1_2"

jQuery(document).on("change","#input_1_2", function(){
    readURL(this);
});
</script>

html block

<div id="imgview"><img src=""></div>

enter image description here

like image 74
Vel Avatar answered Oct 01 '22 22:10

Vel