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

相关内容

热门资讯

透视透视"wepok... 您好,wepoker能不能透视这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302...
透视解谜"wejok... 透视解谜"wejoker私人辅助软件"真是是真的辅助插件(哔哩哔哩)1、wejoker私人辅助软件免...
透视解迷"wpk透视... 透视解迷"wpk透视怎么安装"好像真的是有辅助器(哔哩哔哩)1、下载好wpk透视怎么安装正确养号方法...
透视总结"aapok... 透视总结"aapoker怎么拿好牌"果然是真的辅助工具(哔哩哔哩)1、aapoker怎么拿好牌辅助器...
透视总结"htx矩阵... 透视总结"htx矩阵wepoker辅助"一直是有辅助脚本(哔哩哔哩)该软件可以轻松地帮助玩家将htx...
透视推荐"hhpok... 透视推荐"hhpoker到底可以作必弊吗"切实是真的辅助神器(哔哩哔哩)1、hhpoker到底可以作...
透视详细"德普之星有... 透视详细"德普之星有辅助软件吗"确实真的有辅助软件(哔哩哔哩)亲,关键说明,德普之星有辅助软件吗透视...
透视有挂"wepok... 透视有挂"wepoker作必弊辅助"好像真的有辅助脚本(哔哩哔哩)1、下载好wepoker作必弊辅助...
透视曝光"wepok... 透视曝光"wepoker可以免费玩吗"好像真的是有辅助插件(哔哩哔哩)1、这是跨平台的wepoker...
透视了解"poker... 透视了解"pokernow辅助工具"果然是真的辅助教程(哔哩哔哩)1)pokernow辅助工具免费钻...