上传预览图片
//上传预览 function showFile(data){ var thisfile = $(data).children('input')[0]; contentLoaded(thisfile) } function ProcessFile(items) { var file = $(items).prop ('files')[0]; var img = $(items).parent().parent().prev()[0]; if ( file) { var reader = new FileReader(); reader.onload = function ( event ) { var txt = event.target.result; img.src = txt; }; } reader.readAsDataURL( file ); } function contentLoaded(_this) { _this.addEventListener( 'change' , function(){ ProcessFile(_this); }, false ); }
耐得住寂寞,守得住繁华