node.js - 如何使用 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);
});
});
解决方案
推荐阅读
- visual-studio-code - 如何在 VSCode 中绑定 ctrl-alt-up/down 以像 VS2019 一样工作?
- ios - 科尔多瓦插件相机未在 iPad 电容器上显示画廊
- sql-server - 使用视图的 case 子句
- azure-devops - 如何工作项获取仅更改链接的更改的历史记录项
- performance - 空闲后的非最佳 QnA Maker 应用服务实例行为
- android - Android 动作分享只工作一次
- java - Java中的Leetcode排列问题!列表在这个问题中是如何工作的?
- javascript - 接收二维数组 args 作为 js.Value 并想要一个数组 ([]js.Value)
- ruby-on-rails - Rails 应用程序内的 Rails 引擎中的继承
- c# - 分别从 PowerShell 和 PowerShell 的 C# .Net 库生成的访问令牌长度的差异