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透视... 一分钟方式!wepoker透视有吗(透视)都是是有辅助安装(哔哩哔哩);1、用户打开应用后不用登录就...
第八分钟策略!德普辅助软件(透... 第八分钟策略!德普辅助软件(透视)真是是真的有辅助插件(哔哩哔哩)1、这是跨平台的德普辅助软件轻量版...
十分钟指南书!wepoker怎... 十分钟指南书!wepoker怎么设置透视(透视)其实真的是有辅助工具(哔哩哔哩)在进入wepoker...
第8分钟操作!xpoker辅助... 第8分钟操作!xpoker辅助工具(透视)竟然是有辅助下载(哔哩哔哩)1、每一步都需要思考,不同水平...
第八分钟窍要!德普软件(透视)... 第八分钟窍要!德普软件(透视)其实存在有辅助开挂(哔哩哔哩)该软件可以轻松地帮助玩家将德普软件外卦神...
2分钟法门!德州透视hhpok... 2分钟法门!德州透视hhpoker(透视)真是真的有辅助神器(哔哩哔哩)1、超多福利:超高返利,海量...
3分钟绝活!wepokerpl... 3分钟绝活!wepokerplus外开挂(透视)好像有辅助开挂(哔哩哔哩)该软件可以轻松地帮助玩家将...
4分钟资料!wepoker免费... 您好,wepoker免费脚本弱密码这款游戏可以开挂的,确实是有挂的,需要了解加去威信【4852750...
第7分钟积累!hhpoker哪... 第7分钟积累!hhpoker哪个俱乐部靠谱(透视)确实真的有辅助透视(哔哩哔哩)1、hhpoker哪...