问题描述
<div class="col-lg-12 col-md-12 col-sm-12">
<p-fileUpload name="demo[]" customUpload="true" (uploadHandler)="onUpload($event)" multiple="multiple" accept="image/*"
maxFileSize="1000000">
<ng-template pTemplate="content">
<ul *ngIf="uploadedFiles">
<li *ngFor="let file of uploadedFiles">{{file.name}} - {{file.size}} bytes</li>
</ul>
</ng-template>
</p-fileUpload>
</div>
onUpload(event) {
const formData: FormData = new FormData();
const file = event.files;
formData.append('file',file);
this.uploadService.upload(formData).subscribe(
event => {
});
}
上载服务以调用实际的后端服务。
upload(file: FormData): Observable<any> {
const req = new HttpRequest('POST',CommonConstants.env+"api/master/upload",file,{
responseType: 'json'
});
return this.http.request(req);
}
加载时返回错误“ core.js:6014 ERROR TypeError:无法读取未定义的属性” method“ 在HttpXhrBackend.handle(http.js:2325)“
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)