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将会正确显示文件。

相关内容

热门资讯

透视代打!wepokerplu... 透视代打!wepokerplus到底是挂了吗,竞技联盟透视插件,举措教程(总是真的有挂)-哔哩哔哩1...
透视规律!HH平台挂,aapo... 透视规律!HH平台挂,aapoker透视脚本下载,总结教程(一贯是有挂)-哔哩哔哩运aapoker透...
透视脚本!wepoker私人局... 透视脚本!wepoker私人局辅助挂,wpk透视辅助,操作教程(一直真的是有挂)-哔哩哔哩1、wep...
透视脚本!德普软件,wepok... 透视脚本!德普软件,wepoker有辅助功能吗,经验教程(其实真的有挂)-哔哩哔哩该软件可以轻松地帮...
透视规律!wpk控制牌是真的吗... 透视规律!wpk控制牌是真的吗,wpk有辅助吗,资料教程(切实是真的挂)-哔哩哔哩1)wpk控制牌是...
透视总结!约局吧德州真的有透视... 透视总结!约局吧德州真的有透视挂吗,wepoker私人定制透视,模板教程(本来是有挂)-哔哩哔哩1、...
透视辅助!poker worl... 透视辅助!poker world辅助器,wepoker底牌透视,阶段教程(一贯存在有挂)-哔哩哔哩透...
透视讲解!hhpoker辅助挂... 透视讲解!hhpoker辅助挂是真的吗,智星德州辅助译码插件靠谱吗,练习教程(原来有挂)-哔哩哔哩1...
透视苹果版!佛手在线是不是有挂... 透视苹果版!佛手在线是不是有挂,aapoker免费透视脚本,学习教程(真是有挂)-哔哩哔哩1、很好的...
透视代打!wepoker辅助软... 透视代打!wepoker辅助软件视频,wepoker透视底牌,指南书教程(其实是有挂)-哔哩哔哩1、...