当前位置:网站首页>Ts+fetch to upload selected files
Ts+fetch to upload selected files
2022-06-11 00:41:00 【Chenxiaohao】
Upload the type :File: (binary)
Request header :content-type: multipart/form-data;
html part
<input id="updateImg" type="file"/>
js Code section
const updateImg = document.querySelector<HTMLInputElement>("#updateImg")!;
updateImg.addEventListener('change',(e:any)=>{
const formData = new FormData();
// Parameters
formData.append('File',e.target.files[0]);
fetch('https://api.com/UploadImgFile', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(result => {
console.log('Success:', result);
})
.catch(error => {
console.error('Error:', error);
});
})
边栏推荐
猜你喜欢

【无标题】4555

What is thread in concurrent programming

如何保证消息的顺序性、消息不丢失、不被重复消费
![[network planning] 2.2.4 Web cache / proxy server](/img/a8/74a1b44ce4d8b0b1a85043a091a91d.jpg)
[network planning] 2.2.4 Web cache / proxy server

How word inserts a guide (dot before page number) into a table of contents

Installation of phpstudy
![[JVM] thread](/img/fc/c1f2eeaca639f319a4ef33f5fa6658.png)
[JVM] thread

763. dividing alphabetic intervals

如何在office2016(word2016)中安装mathtype6.9及相关问题解决方案

亿级搜索系统(优酷视频搜索)的基石,如何保障实时数据质量?v2020
随机推荐
系统应用安装时,签名校验失败问题
Download Google gcr IO image
[JVM] memory model
Unity custom folder icon color personalized unity compiler
阻塞隊列 — DelayedWorkQueue源碼分析
[database] MySQL index interview questions
非重叠矩形中的随机点
How to handle file cache and session?
数组的字典排序
Kwai handled more than 54000 illegal accounts: how to crack down on illegal accounts on the platform
富文本活动测试1
Multipass Chinese documentation - Tutorial
如何在office2016(word2016)中安装mathtype6.9及相关问题解决方案
Dual wing layout
Test it first
微信小程序实现OCR扫描识别
【数据库】Mysql索引面试题
Excel cell
Go language channel understanding and use
AQS explanation of concurrent programming