图床

简单高效的图片上传工具

API文档

本图床提供简单的API接口,方便开发者集成图片上传功能。

上传图片

POST
/api.php

请求参数

参数名 类型 必填 描述
file file 要上传的图片文件

成功响应

{"success": true, "url": "http://example.com/uploads/123456.jpg", "name": "example.jpg", "message": "上传成功"}

失败响应

{"success": false, "message": "错误信息"}

测试API

使用示例

cURL

curl -X POST -F "file=@/path/to/image.jpg" http://example.com/api.php

Python

import requests

url = 'http://example.com/api.php'
files = {'file': open('image.jpg', 'rb')}
response = requests.post(url, files=files)
print(response.json())

JavaScript (Fetch)

const formData = new FormData();
formData.append('file', fileInput.files[0]);

fetch('http://example.com/api.php', {
    method: 'POST',
    body: formData
})
.then(response => response.json())
.then(data => console.log(data));