获得徽章 1
有哪位大佬能够帮忙看一下吗,求求了


import axios from 'axios';
import React from 'react'
import { useState } from 'react';

export default function TestPage2() {

const [file,setFile]=useState('')
let changeHandler=(evt)=>{
setFile(evt.target.files[0])
console.log (file);
}
let clickHandler=()=>{
const fd=new FormData();
fd.append('file',file);
axios.post('http://123.56.9.154:8081/file/upload', fd, {
headers: {
'Content-Type': 'application/json'
}
})
.then(res=>{
console.log('upload success');
})
.catch(err=>{
console.log(err);
})
}

return (
<div>Testpage2
<div>
<input type='file' onChange={changeHandler}/>
<button onClick={clickHandler}>上传</button>
</div>
</div>
)
}
展开
junjun于2023-05-19 17:20发布的图片
21
下一页
个人成就
文章被点赞 12
文章被阅读 2,549
掘力值 334
收藏集
1
关注标签
0
加入于