第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Angular 8 將圖像上傳到 ApiController c# 從 Angular 7

Angular 8 將圖像上傳到 ApiController c# 從 Angular 7

C#
一只斗牛犬 2023-09-09 16:15:58
我正在使用 Angular 8。我將圖像發(fā)送到我的 ApiController 來保存圖像。我在 Angular 7 之前使用過,一切正常,升級(jí)到 Angular 8 后我沒有收到該文件。當(dāng)我發(fā)送時(shí),我在控制臺(tái)中看到文件的名稱和長(zhǎng)度,但在 Api 中沒有看到它。我在這里缺少什么?我的角度 tsimport { timeout } from 'rxjs/operators';import { UserClaims } from './../../authentication/models/user-claims.model';import { PrivateZoneLoginService } from './../private-zone-login.service';import { Component, OnInit } from '@angular/core';import { MatBottomSheetRef } from '@angular/material/bottom-sheet';import { HttpClient } from '@angular/common/http';import { LocalStorageService } from 'src/app/app-services/local-storage.service';import { PrivateZoneConstants } from '../private-zone-constans';@Component({  selector: 'app-bottom-sheet',  templateUrl: './bottom-sheet.component.html',  styleUrls: ['./bottom-sheet.component.css']})export class BottomSheetComponent implements OnInit {  token = this.pzLogin.userLoginAccessToken;  public imagePath;  imgURL: any = this.pzLogin.UserLoginClaims.ImageUrl;  public message: string;  fileData = new FileReader();  reader = new FileReader();  fileUploaded: boolean = false;   loading: boolean = false;  constructor(    private _bottomSheetRef: MatBottomSheetRef<BottomSheetComponent>,    private http: HttpClient, private pzLogin: PrivateZoneLoginService,    private localStorageService: LocalStorageService) { }  openLink(event: MouseEvent): void {    this._bottomSheetRef.dismiss();    event.preventDefault();  }  ngOnInit() {  }  preview(event) {    if (event.files.length === 0) {      return;    }    const mimeType = event.files[0].type;    if (mimeType.match(/image\/*/) == null) {      this.message = 'Only images are supported.';      return;    }    const fileSize = event.files[0].size;    if (fileSize > 500839) {      this.message = 'Maximum upload file size 200 kb.';      return;    }
查看完整描述

1 回答

?
慕少森

TA貢獻(xiàn)2019條經(jīng)驗(yàn) 獲得超9個(gè)贊

您需要自己添加標(biāo)題。


并檢查您的 HttpInterceptor 是否不會(huì)覆蓋您的標(biāo)頭


這將解決問題


const HttpUploadOptions = new HttpHeaders();

HttpUploadOptions.append('Content-Type', 'multipart/form-data');

HttpUploadOptions.append('Accept', 'image/x-png,image/gif,image/jpeg');


this.http.post(PrivateZoneConstants.UploadUserImage, formData, 

  {

  headers: HttpUploadOptions,

  reportProgress: true

}).subscribe(res => {

    this.localStorageService.setItem('UserLoginClaims', res);

    this.fileUploaded = true;

    this.loading = false;

    this._bottomSheetRef.containerInstance.enter();

  });


查看完整回答
反對(duì) 回復(fù) 2023-09-09
  • 1 回答
  • 0 關(guān)注
  • 105 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)