<label> <div class="myusercenter-image-none"> <img src="" class="myusercenter-image" alt=""> <input type="file" class="myusercenter-hard-img"> </div> </label>
// 上传头像 $(function() { $('.myusercenter-hard-img').on('change', function(e) { var files = e.target.files; var reader = new FileReader(); reader.readAsDataURL(files[0], "UTF-8"); reader.onload = function(evt) { var fileString = evt.target.result; var date = { "file": fileString }; $('.myusercenter-image').attr('src', fileString); console.log(fileString) // $.post("", date).success(function (result) { // alert("ok"); // }); } }) })