【问题标题】:imgbb upload image in an album via apiimgbb 通过 api 在相册中上传图片
【发布时间】:2021-09-24 09:16:13
【问题描述】:

我在使用 imgbb API 时遇到问题 通过 imgbb API,我一直在尝试将图像上传到我在 imgbb 上创建的相册。但到目前为止我找不到任何信息......(我已经在谷歌上搜索了 3 个小时,哈哈) 有人知道在相册中保存图片要添加什么吗?

这是我的代码。

感谢阅读:)

let body = new FormData()
body.set('key', 'my-api-key')
body.append('image', File)


axios.post('https://api.imgbb.com/1/upload/', body)
    .then((response) => {
        console.log('response', response)
        console.log('response URL', response.data.data.image.url)
        console.log('success')
    })
    .catch((error) => {
        console.log('error', error)
        alert('try agian')
    })  enter code here

【问题讨论】:

    标签: node.js reactjs axios


    【解决方案1】:

    来自文档

    curl --location --request POST "https://api.imgbb.com/1/upload?expiration=600&key=YOUR_CLIENT_API_KEY" --form "image=R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
    

    试试这个

    let payload = new FormData()
    payload.append('image', File)
    
    
    axios.post('https://api.imgbb.com/1/upload?expiration=600&key=YOUR_CLIENT_API_KEY', payload)
        .then((response) => {
            console.log('response', response)
            console.log('response URL', response.data.data.image.url)
            console.log('success')
        })
        .catch((error) => {
            console.log('error', error)
            alert('try agian')
        }) 
    

    【讨论】:

    • 感谢您的回答 :) 我认为您的建议是在 imgbb 服务器上上传照片。但是上传照片对我来说不是问题。我无法在我的 imgbb 服务器上的相册(文件夹)中上传图像:(
    猜你喜欢
    • 1970-01-01
    • 2021-12-28
    • 1970-01-01
    • 1970-01-01
    • 2022-07-26
    • 1970-01-01
    • 2011-02-21
    • 2019-02-16
    • 1970-01-01
    相关资源
    最近更新 更多