Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.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
Html 在4中过帐数据时出现网络错误_Html_Angular_Typescript_Angular Httpclient - Fatal编程技术网

Html 在4中过帐数据时出现网络错误

Html 在4中过帐数据时出现网络错误,html,angular,typescript,angular-httpclient,Html,Angular,Typescript,Angular Httpclient,我在学英语。我试图发布一个带有关键字的文件。上载时,我在网页控制台中遇到以下错误 代码:19 列数:0 数据:空 文件名:“ 电话号码:5291 消息:“发生网络错误。” 名称:“网络错误” 结果:2152923155 这就是我试图上传文件的方式 .service文件中的方法 url: String = 'localhost:8080/file-uploader/rest/file/'; getFileName(fileToUpload: File, columnHeading

我在学英语。我试图发布一个带有关键字的文件。上载时,我在网页控制台中遇到以下错误

代码:19 列数:0 数据:空 文件名:“ 电话号码:5291 消息:“发生网络错误。” 名称:“网络错误” 结果:2152923155

这就是我试图上传文件的方式

.service文件中的方法

  url: String = 'localhost:8080/file-uploader/rest/file/';

      getFileName(fileToUpload: File, columnHeading: any) {
        const httpOptions = {
          headers: new HttpHeaders({
            'Content-Type': 'multipart/form-data',
          })
        };
        const body = {
          file: fileToUpload,
          columnHeading: columnHeading
        };
        return this.http.post<UploadResponse['path']>(this.url + 'upload', body, httpOptions);
      }
interface UploadResponse {
  path: string;
}
  uploadFile() {
    this.httpService.getFileName(this.file, this.columnHeading).subscribe(
      res => {
        localStorage.setItem('filePath', res);
      }
    );
  }
<div>
  <input type="file" [(ngModel)]="file" name="file">
  <br>
  <input type="text" [(ngModel)]="columnHeading" name="columnHeading">
  <br>

  <!-- (click) passes input value to add() and then clears the input -->
  <button (click)="uploadFile()">
    Upload File
  </button>
</div>
文件上载类型脚本文件

  url: String = 'localhost:8080/file-uploader/rest/file/';

      getFileName(fileToUpload: File, columnHeading: any) {
        const httpOptions = {
          headers: new HttpHeaders({
            'Content-Type': 'multipart/form-data',
          })
        };
        const body = {
          file: fileToUpload,
          columnHeading: columnHeading
        };
        return this.http.post<UploadResponse['path']>(this.url + 'upload', body, httpOptions);
      }
interface UploadResponse {
  path: string;
}
  uploadFile() {
    this.httpService.getFileName(this.file, this.columnHeading).subscribe(
      res => {
        localStorage.setItem('filePath', res);
      }
    );
  }
<div>
  <input type="file" [(ngModel)]="file" name="file">
  <br>
  <input type="text" [(ngModel)]="columnHeading" name="columnHeading">
  <br>

  <!-- (click) passes input value to add() and then clears the input -->
  <button (click)="uploadFile()">
    Upload File
  </button>
</div>
文件上载html标记文件

  url: String = 'localhost:8080/file-uploader/rest/file/';

      getFileName(fileToUpload: File, columnHeading: any) {
        const httpOptions = {
          headers: new HttpHeaders({
            'Content-Type': 'multipart/form-data',
          })
        };
        const body = {
          file: fileToUpload,
          columnHeading: columnHeading
        };
        return this.http.post<UploadResponse['path']>(this.url + 'upload', body, httpOptions);
      }
interface UploadResponse {
  path: string;
}
  uploadFile() {
    this.httpService.getFileName(this.file, this.columnHeading).subscribe(
      res => {
        localStorage.setItem('filePath', res);
      }
    );
  }
<div>
  <input type="file" [(ngModel)]="file" name="file">
  <br>
  <input type="text" [(ngModel)]="columnHeading" name="columnHeading">
  <br>

  <!-- (click) passes input value to add() and then clears the input -->
  <button (click)="uploadFile()">
    Upload File
  </button>
</div>



上载文件
此.url的
值是多少?这应该更像
返回this.http.post(this.url+/upload',body,httpOptions)谢谢,我将用这些值编辑问题。