gravity form preview of image upload

蓝咒 提交于 2019-12-04 22:16:32

问题


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?


回答1:


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>



来源:https://stackoverflow.com/questions/37880725/gravity-form-preview-of-image-upload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!