我是新來的打字稿,並嘗試從移動SD卡上傳圖片。瀏覽圖像時,我正在獲取圖像路徑。當我通過這個表單數據時,無返回。如果有人幫助解決問題,這將是非常棒的。使用移動表單數據的打字稿圖片上傳返回無
我使用「nativescript-imagepicker」庫從SD卡獲取圖像..
sendPicture(uri: string, modelContext: any){
let _formData = new FormData();
_formData.append("profile_image", uri);
let body = _formData;
updateAvatarService(this.userToken,body).subscribe(data => {
});
}
updateAvatarService(token,body): Observable<any> {
return this.httpClass.patchMethodWithToken(URL,token,body)
.map(response => {
return response;
})
}
patchMethodWithToken(url: string, token: string, data: Object) {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Authorization', "Token " + token);
headers.append('Content-Disposition', "form-data");
let options = new RequestOptions({ headers: headers });
if (this.checkNetworkConnection()) {
return this.http
.patch(url, JSON.stringify(data), options)
.map(response => {
return response.json();
})
.catch(this.handleErrors);
}
}
提供代碼 – Dlucidone
更多信息請檢查我現在已經增加了代碼.. – vishnuc156