如何使用axios从客户端向nodejs服务器发送图像和数据

时间:2018-05-03 08:36:55

标签: javascript node.js reactjs axios

我正在使用reactjs并在表单中发送与之关联的图像和数据。

$stmt->lastInsertId();

现在在服务器端

$stmt->execute();

我认为发送文件的方式是个问题,但我无法找到来自客户端axios的请求结构。欢迎提出建议和建议

错误:意外令牌

 <form>
<input type='file' name='image'/>
</form>

let formdata = new formData();
formdata.append('file',file);
formdata.append(data,data);
let output = axios({
methodname=post,
path = '/image',
header = {
       auth : token,
       content-type: multipart/form-data
         },
data : formdata
})

formdata = { file: (file)
             data:{
                title:'',
                desc:''
                  }
}

0 个答案:

没有答案