js 上傳頭像img
阿新 • • 發佈:2018-09-05
src read col att file dataurl load ada 頭像
<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"); // }); } }) })
js 上傳頭像img