Angular上传视频文件后video_url不显示文件
创始人
2024-10-29 10:00:44
0

在组件中增加以下代码:

import { Component, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
fileData: File = null;
@ViewChild(NgForm) form: NgForm;
constructor(private http: HttpClient) { }
onFileSelect(event) {
if (event.target.files.length > 0) {
const file = event.target.files[0];
this.fileData = file;
}
}
onSubmit() {
const formData = new FormData();
formData.append('file', this.fileData);
this.http.post('/api/upload', formData)
.subscribe(res => {
console.log(res);
this.form.reset();
});
}
}

另外,需要在上传文件的API中,添加Content-Disposition头部,如下所示:

Content-Disposition: attachment;filename="your_file_name.jpg"

这样就可以成功上传视频文件,并且video_url将会正确显示文件。

相关内容

热门资讯

九分钟辅助!hhpoker免费... 九分钟辅助!hhpoker免费辅助器,wepoker私人局怎么玩,攻略教程(有挂秘笈)1、任何wep...
第1分钟辅助!拱趴大菠萝作弊方... 第1分钟辅助!拱趴大菠萝作弊方法,德州局hhpoker,指南教程(证实有挂)1、游戏颠覆性的策略玩法...
第6分钟辅助!wepoker脚... 第6分钟辅助!wepoker脚本下载,wepoker透视挂底牌,演示教程(有挂猫腻)1、玩家可以在w...
第9分钟辅助!wejoker辅... 第9分钟辅助!wejoker辅助器要钱玩吗,aapoker辅助器是真的吗,练习教程(有挂工具)1、该...
第十分钟辅助!pokeplus... 第十分钟辅助!pokeplus脚本,wepoker辅助器安装包,攻略教程(有挂秘笈)1、操作简单,无...
四分钟辅助!newpoker怎... 您好,newpoker怎么安装脚本这款游戏可以开挂的,确实是有挂的,需要了解加去威信【4852750...
十分钟辅助!wepoker有人... 十分钟辅助!wepoker有人用过吗,wepoker私局代打,课程教程(有挂秘笈)1、wepoker...
4分钟辅助!wpk真吗,wep... 4分钟辅助!wpk真吗,wepoker免费脚本咨询,资料教程(有挂解密)1、wepoker免费脚本咨...
第一分钟辅助!wpk俱乐部辅助... 第一分钟辅助!wpk俱乐部辅助器,wepoker俱乐部辅助,积累教程(有挂教学)1、在wepoker...
第二分钟辅助!wejoker黑... 第二分钟辅助!wejoker黑侠辅助器,xpoker透视辅助,项目教程(有挂工具)1、在wejoke...