...
|
...
|
@@ -210,34 +210,37 @@ |
|
|
$('.save').click(function () {
|
|
|
var file = document.getElementById("previewImg").files[0];
|
|
|
console.log(file);
|
|
|
var formData = new FormData();
|
|
|
formData.append('file',file);
|
|
|
$.ajax({
|
|
|
url: "{:url('Member/change')}",
|
|
|
type: "POST",
|
|
|
data: formData,
|
|
|
/**
|
|
|
*必须false才会自动加上正确的Content-Type
|
|
|
*/
|
|
|
contentType: false,
|
|
|
/**
|
|
|
* 必须false才会避开jQuery对 formdata 的默认处理
|
|
|
* XMLHttpRequest会对 formdata 进行正确的处理
|
|
|
*/
|
|
|
processData: false,
|
|
|
success: function (data) {
|
|
|
if(data.code == 1){
|
|
|
$('#imghead').attr('src',data.data[0]);
|
|
|
popup('上传成功');
|
|
|
}else{
|
|
|
popup(data.message)
|
|
|
if(file.length != 0){
|
|
|
var formData = new FormData();
|
|
|
formData.append('file',file);
|
|
|
$.ajax({
|
|
|
url: "{:url('Member/change')}",
|
|
|
type: "POST",
|
|
|
data: formData,
|
|
|
/**
|
|
|
*必须false才会自动加上正确的Content-Type
|
|
|
*/
|
|
|
contentType: false,
|
|
|
/**
|
|
|
* 必须false才会避开jQuery对 formdata 的默认处理
|
|
|
* XMLHttpRequest会对 formdata 进行正确的处理
|
|
|
*/
|
|
|
processData: false,
|
|
|
success: function (data) {
|
|
|
if(data.code == 1){
|
|
|
$('#imghead').attr('src',data.data[0]);
|
|
|
popup('上传成功');
|
|
|
}else{
|
|
|
popup(data.message)
|
|
|
}
|
|
|
console.log(data);
|
|
|
},
|
|
|
error: function () {
|
|
|
alert("上传失败!");
|
|
|
}
|
|
|
console.log(data);
|
|
|
},
|
|
|
error: function () {
|
|
|
alert("上传失败!");
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
</script>
|
...
|
...
|
|