Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.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
Angular 角度文件上载无法使用formData_Angular_Typescript_Http Headers - Fatal编程技术网

Angular 角度文件上载无法使用formData

Angular 角度文件上载无法使用formData,angular,typescript,http-headers,Angular,Typescript,Http Headers,我试图上传多个文件上传在Angular 7这里是html代码 <form [formGroup]="exceptionChangeStatusForm" (ngSubmit)="submitChangeStatusForm()" enctype="multipart/form-data"> <div class="form-group"> <label>Documents:</label>

我试图上传多个文件上传在Angular 7这里是html代码

<form [formGroup]="exceptionChangeStatusForm" (ngSubmit)="submitChangeStatusForm()" enctype="multipart/form-data">
        <div class="form-group">
            <label>Documents:</label>
            <input type="file" name="documents" multiple (change)="exceptionCommentFileChange($event)"/>
        </div>
        <div class="form-group" style="text-align:center;">
            <button type="submit" class="btn btn-primary">Save</button>
        </div>
    </form>
我创建了formData,用于通过api发送文件

submitChangeStatusForm() {

    const formData = new FormData();
    const documents = this.addExceptionCommentForm.get('documents').value;
    for ( let i = 0; i < documents.length; i++) {
        formData.append('documents', documents[i], documents[i]['name']);
    }
    this.http.post(environment.exceptionsApiUrl, formData).pipe();
}
我正在尝试将内容类型更改为多部分/表单数据,但它没有更改

return this.http.post(environment.exceptionsApiUrl + url, params, {headers : {
    'Content-Type': 'multipart/form-data',
    'Accept': 'application/json',
  }}).pipe();
我的请求负载是这样的

------WebKitFormBoundaryqe260o3UOMqEKW2A
Content-Disposition: form-data; name="documents"; filename="1.jpeg"
Content-Type: image/jpeg

当我尝试从邮递员它的工作,但从角度它是不工作的,我从api得到400响应时,我尝试从角度。请告诉我是否需要进行任何更改。

您是否解决了此问题?我也面临着同样的问题,曾经工作但突然停止了working@javapedia.net在interceptor中,我给出了只接受“application/json”的条件,在删除该条件后,它开始工作,通过绕过interceptor来解决。您解决了这个问题吗?我也面临着同样的问题,曾经工作但突然停止了working@javapedia.net在拦截器中,我给出了只接受“application/json”的条件,在删除该条件后,它开始工作,通过绕过拦截器来解决
return this.http.post(environment.exceptionsApiUrl + url, params, {headers : {
    'Content-Type': 'multipart/form-data',
    'Accept': 'application/json',
  }}).pipe();
------WebKitFormBoundaryqe260o3UOMqEKW2A
Content-Disposition: form-data; name="documents"; filename="1.jpeg"
Content-Type: image/jpeg