| 名称 | 必填 | 类型 | 说明 |
|---|---|---|---|
| image | 是 | 是 | 图片二进制 |
| upload_type | 是 | 是 | 上传图床,58/imgdd |
{
"url": "https:\/\/pic5.58cdn.com.cn\/nowater\/webim\/big\/n_v232d0faaceda04e81a07ff54e06693421.png"
}
接口容易拉黑服务器,不保证正常
不会的可以直接使用:
https://jk.lllt.top/api/tuchuang/
或者(type=58/imgdd):
https://jk.lllt.top/api/tuchuang/api.php?type=58&url=https://img.imgdd.com/f210f3.4973c6b5-8080-4ca7-a6b0-8bdb3645d58d.png
调用代码:
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Access-Control-Max-Age: 86400');
header('Content-Type: application/json; charset=utf-8');
function upload_image_via_post($uploadUrl, $filePath, $uploadType)
{
$postFields = [
'image' => new \CURLFile($filePath),
'upload_type' => $uploadType
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uploadUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$uploadUrl = 'https://jk.lllt.top/api/tuchuang/upload.php'; // 你的 PHP 脚本 URL
$filePath = isset($_REQUEST['url']) ? $_REQUEST['url'] :''; // 图片文件路径
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'imgdd'; // '58' 或 'imgdd'
$response = upload_image_via_post($uploadUrl, $filePath, $type);
echo $response;
赞助一下