You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过imgbb API将图片上传到自己创建的指定相册?

解决方案

你只需要在提交的FormData中新增album参数即可将图片存入指定相册,参数值为目标相册的ID。

相册ID获取方式

登录imgbb账号后打开目标相册页面,浏览器地址栏中album/路径后的字符串就是相册ID。

修改后的代码

let body = new FormData()
body.set('key', 'my-api-key')
body.append('image', File)
// 新增此行,替换为你自己的目标相册ID
body.append('album', '你的相册ID')

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 again')
    })

注意事项

  • 使用的API密钥必须和创建目标相册的账号对应,否则没有写入权限
  • album参数仅支持传入相册ID,传入自定义相册名称无法识别

内容的提问来源于stack exchange,提问作者heyjay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 22:36:03