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

相关内容

热门资讯

黑科技软件(Wepoke大厅)... 黑科技软件(Wepoke大厅)外挂透明挂辅助助手(透明挂)一直真的有挂(有挂方式)-哔哩哔哩1、点击...
黑科技代打(WPK程序)外挂透... 黑科技代打(WPK程序)外挂透明挂辅助AI(透明挂)切实是真的有挂(有挂教程)-哔哩哔哩1、黑科技代...
黑科技好牌(WPK科技)外挂透... 黑科技好牌(WPK科技)外挂透明挂辅助插件(透视)一直存在有挂(有挂方法)-哔哩哔哩进入游戏-大厅左...
黑科技科技(新Wepoke)外... 黑科技科技(新Wepoke)外挂透明挂辅助代打(ai代打)原来是有挂(有挂助手)-哔哩哔哩1、新We...
黑科技脚本(aapoker俱乐... 黑科技脚本(aapoker俱乐部)外挂透明挂辅助神器(透明挂黑科技)原来真的有挂(确实有挂)-哔哩哔...
黑科技软件(wepoke脚本)... 黑科技软件(wepoke脚本)外挂透明挂辅助插件(透明挂黑科技)竟然真的有挂(有挂教学)-哔哩哔哩1...
黑科技好牌(WPK透视挂)外挂... 黑科技好牌(WPK透视挂)外挂透明挂辅助助手(软件透明挂)原来真的有挂(有挂方针)-哔哩哔哩1、下载...
黑科技存在(Wepoke后台)... 黑科技存在(Wepoke后台)外挂透明挂辅助ai代打(透明挂黑科技)竟然真的有挂(有挂详情)-哔哩哔...
黑科技总结(wepoke最新)... 黑科技总结(wepoke最新)外挂透明挂辅助助手(透视)竟然真的有挂(有挂秘诀)-哔哩哔哩1、完成w...
黑科技中牌率(WPK漏洞)外挂... 黑科技中牌率(WPK漏洞)外挂透明挂辅助器(透明挂黑科技)一直真的是有挂(有挂秘籍)-哔哩哔哩1、进...