input file字段选择图片之后怎么实现预览(还未上传到服务器的情况下)

$("#txt_image").on('change',function(){
	 			console.log('on change');

	 			if (this.files && this.files[0] ) {
	 				const reader = new FileReader();

	 				reader.onload = function(e){
	 					$("#book-image-preview").attr('src',e.target.result);

	 				}

	 				reader.readAsDataURL(this.files[0]);

	 			}
	 			
	 		});

Leave a Reply

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