这是代码,明明已经把file赋给body,可是在浏览器发送请求时根本没有requestpayload,后端也看不见数据,请问这是为何?import React, { Component } from 'react';let a=1;class Upload extends Component{ state = { file:null } handleFileClick(e) { this.setState({file: e.target.files[0]}); } handleSubmitClick(e) { console.log(this.state.file); fetch("http://localhost:8080//upload.do",{ method: 'POST', headers:{ 'Access-Control-Allow-Origin':'*', 'Content-Type': 'multipart/form-data;boundary=56423498738365' }, mode: 'cors', body: this.state.file }); } render(){ return ( <div> <input type="file" onChange={this.handleFileClick.bind(this)}/> <input type="button" value="123" onClick={this.handleSubmitClick.bind(this)}/> </div> ); }}export default Upload;
添加回答
举报
0/150
提交
取消