首页 > 解决方案 > 如何使用 node.js 向图像服务器发出 post 请求

问题描述

我正在尝试将图像上传到图像服务器,代码没有问题,但由于某种原因,图像服务器只是返回错误。有谁知道代码有什么问题吗?

const axios = require("axios");
const fs = require("fs")

fs.readFile('image.png', (err, data) => {
  if (err) throw err;
  console.log(data);
    axios.post('https://img.ays.best/upload.php', {
  image: data,
  password: `i put my real password here`
}).then((response) => {
  console.log(response.data);
}, (error) => {
  console.log(error);
});
});

标签: node.js

解决方案


推荐阅读