$(page).off().on('change', '#myUploadImgAlbum', function () {
fileUpload(this.files[0]);
});
var fileUpload = function (obj) {
var file = obj;
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function () {
var img = new Image(),
canvas = document.createElement("canvas"),
drawer = canvas.getContext("2d");
img.src=reader.result;
canvas.width = 400;
canvas.height = 400;
drawer.drawImage(img, 0, 0, 400, 400);
console.log(drawer);
img.src = canvas.toDataURL('image/png', 0.6);
var image_base64 = img.src.replace("data:image/png;base64,","");
$.ajax({
type: 'POST',
headers: reqUrl.getReqHeader(),
url: reqUrl.getReqUrl('UploadPicure'),
data: JSON.stringify({
AgentLogoMsg: image_base64,
FileName: '11.jpg'
}),
success: function (data) {
if (data['Code'] == 0) {
agent.setAgentLogo(data.Data.Logo);
$(page).find('#preview_img').attr('src', data.Data.Logo);
}
},
error:function(data){
console.log(data);
}
})
}
}
添加回答
举报
0/150
提交
取消