From 9c0f5cdaf0196bf0c0ba36ebd758792a99578598 Mon Sep 17 00:00:00 2001 From: woon Date: Wed, 12 Apr 2023 11:49:35 +0800 Subject: [PATCH] update --- public/index.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/public/index.php b/public/index.php index 70b7d65..2ba8d57 100644 --- a/public/index.php +++ b/public/index.php @@ -244,12 +244,14 @@ function api_test() function api_upload() { + $web = "https://demo.winxg.com"; + $url = "https://telegra.ph/upload"; - - $filePath = $_FILES["file"]["tmp_path"]; + $filePath = $_FILES["file"]["tmp_name"]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'file' => new CURLFile($filePath) )); @@ -257,15 +259,14 @@ function api_upload() curl_close($ch); $jsonArr = json_decode($response, true); - $src = $jsonArr[0]["src"] ?? ""; - + echo_json([ "code" => empty($src) ? 1 : 0, "msg" => "", "data" => [ "id" => $_POST["id"], - "src" => $src + "src" => $web . $src ] ]);