update
This commit is contained in:
+21
-3
@@ -244,14 +244,32 @@ function api_test()
|
||||
|
||||
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([
|
||||
"code" => 0,
|
||||
"msg" => "success",
|
||||
"code" => empty($src) ? 1 : 0,
|
||||
"msg" => "",
|
||||
"data" => [
|
||||
"id" => $_POST["id"],
|
||||
"src" => 123
|
||||
"src" => $src
|
||||
]
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// api func end
|
||||
|
||||
Reference in New Issue
Block a user