图片上传 预览 及 获取base64

<div class="row">
                                <div class="col-lg-1 form-group">
                                    
                                    "file" name="file" class="img_upload_file" multiple="multiple" style="display: none" /> 
                                    "hidden" name="img_upload_base" class="img_upload_base" />
                                div>
                                <div class="col-lg-2 form-group">
                                     class="img_upload_show" />
                                div>
                            div>

$(".img_upload_btn").click(function() {
            $(".img_upload_file").click();
        });
        $(".img_upload_file").change(function() {
            var file = this.files[0];
            var reader = new FileReader();
            reader.readAsDataURL(file);
            reader.onload = function(e) {
                $(".img_upload_show").attr("src", this.result);
                $(".img_upload_base").val(this.result);
            };
        });

你可能感兴趣的:(javascript)