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

相关内容

热门资讯

带你了解!aapoker透视脚... 带你了解!aapoker透视脚本,微扑克辅助下载,都是是有挂(有人有挂)1、上手简单,内置详细流程视...
玩家必备科技!hhpoker智... 玩家必备科技!hhpoker智能辅助插件,hhpoker免费透视脚本,确实有挂(确实有挂)1)辅助插...
玩家必看教程!aa poker... 玩家必看教程!aa poker辅助,aapoker透视插件,一贯有挂(有挂技巧)1、下载好正确养号方...
我来分享!wepoker透视脚... 我来分享!wepoker透视脚本是什么,hhpoker辅助软件是真的么,本来真的有挂(存在有挂)1、...
重大通报!德普辅助器怎么用,h... 重大通报!德普辅助器怎么用,hhpkoer辅助挂是真的吗,一直是真的有挂(有挂辅助)1、脚本辅助下载...
研究成果!wpk辅助,soho... 研究成果!wpk辅助,sohoo poker辅助器,竟然真的有挂(有挂总结)1、破解器简单,机器人操...
三分钟了解!德普之星辅助软件,... 三分钟了解!德普之星辅助软件,德州透视插件,确实真的有挂(的确有挂)进入游戏-大厅左侧-新手福利-激...
必备科技!wepoker私人局... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在这款游戏中打...
推荐几款新版!aapoker真... 推荐几款新版!aapoker真的假的,wepoker养号规律,果然是真的有挂(有挂详情)1、脚本辅助...
推荐一款!werplan怎么作... 推荐一款!werplan怎么作弊,cloudpoker外挂,竟然有挂(有挂方式)亲,关键说明,透视脚...