Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript p-fileUpload多个文件上载错误_Typescript_Angular8_Primeng - Fatal编程技术网

Typescript p-fileUpload多个文件上载错误

Typescript p-fileUpload多个文件上载错误,typescript,angular8,primeng,Typescript,Angular8,Primeng,prime ng file upload htm代码,用于上载多个文件 <div class="col-lg-12 col-md-12 col-sm-12"> <p-fileUpload name="demo[]" customUpload="true" (uploadHandler)="onUpload($event)" multiple="multiple"

prime ng file upload htm代码,用于上载多个文件

 <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>
上载服务以调用实际的后端服务

upload(file: FormData): Observable<any> {

   const req = new HttpRequest('POST', CommonConstants.env+"api/master/upload", file, {
     responseType: 'json'
   });

   return this.http.request(req);

 }
上传(文件:FormData):可观察{
const req=new HttpRequest('POST',CommonConstants.env+“api/master/upload”,文件{
responseType:'json'
});
返回这个.http.request(req);
}
加载时返回错误“core.js:6014 error TypeError:无法读取未定义的属性“method” 位于HttpXhrBackend.handle(http.js:2325)”

upload(file: FormData): Observable<any> {

   const req = new HttpRequest('POST', CommonConstants.env+"api/master/upload", file, {
     responseType: 'json'
   });

   return this.http.request(req);

 }