我在Angular 7中有带有进度栏的上传脚本,上传效果很好。现在我想处理来自php文件的响应(new_filename,... json格式)。我尝试了pipe (). map ()
,但很遗憾没有成功。
是否可以在订阅部分扩展php-response?
谢谢!
onUpload() {
const fd = new FormData();
fd.append('file', this.selectedFile, this.selectedFile.name);
this.http.post('http://xxxxx/upload.php', fd, {
reportProgress: true,
observe: 'events'
}).subscribe( event => {
if (event.type === HttpEventType.UploadProgress) {
this.fileUpload.status = 'progress';
this.fileUpload.message = Math.round(event.loaded / event.total * 100);
} else if (event.type === HttpEventType.Response) {
console.log('events', event);
}
});
}