Browse Source

[WHAT] uplad avartar 未完成 [WHY] 開發 ShowEasy 前台

Dev
Janie 2 years ago
parent
commit
67f49738e7
  1. 34
      FrontEnd/pages/user/editPersonalInfo.vue

34
FrontEnd/pages/user/editPersonalInfo.vue

@ -267,6 +267,11 @@ export default {
},
errors: null,
userPic: {},
payload:{
picName: "",
picSize: "",
picType: "",
},
};
},
created() {
@ -419,16 +424,25 @@ export default {
this.$refs.uploader.click();
},
userPictureUpload(e) {
const payload = new FormData();
//const payload = new FormData();
//payload.append("file", e.target.files[0].name);
payload.append("file", e.target.files[0]);
this.userPic = payload.map((item) => {
return{
name: item.name,
size: item.size,
type: item.type,
}
})
const name = (JSON.stringify(e.target.files[0].name)).toString();
const size = (JSON.stringify(e.target.files[0].size)).toString();
const type = (JSON.stringify(e.target.files[0].type)).toString();
console.log("size:" + name);
//this.payload.push(name, size, type);
this.payload.picName = name;
this.payload.picSize = size;
this.payload.picType = type;
console.log("payload:" + JSON.stringify(this.payload));
const fileSize = (e.target.files[0].size / 1024 / 1024).toFixed(1);
if (fileSize >= 2) {
this.fileTooBig = !this.fileTooBig;
@ -437,7 +451,7 @@ export default {
//.post("/users/images", payload)
//.post("/trending/api/Members/UploadAvatar)
.post(
`/trending/api/Members/UploadAvatar?MemberPicture=${this.userPic}`
`/trending/api/Members/UploadAvatar`
)
.then((response) => {
console.log(JSON.stringify(response));

Loading…
Cancel
Save