This commit is contained in:
2023-04-12 11:29:11 +08:00
parent c7d103a789
commit 2bd157debb
+21 -3
View File
@@ -244,14 +244,32 @@ function api_test()
function api_upload() function api_upload()
{ {
$url = "https://telegra.ph/upload";
$filePath = $_FILES["file"]["tmp_path"];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'file' => new CURLFile($filePath)
));
$response = curl_exec($ch);
curl_close($ch);
$jsonArr = json_decode($response, true);
$src = $jsonArr[0]["src"] ?? "";
echo_json([ echo_json([
"code" => 0, "code" => empty($src) ? 1 : 0,
"msg" => "success", "msg" => "",
"data" => [ "data" => [
"id" => $_POST["id"], "id" => $_POST["id"],
"src" => 123 "src" => $src
] ]
]); ]);
} }
// api func end // api func end