diff --git a/app/tencent/controller/Index.php b/app/tencent/controller/Index.php new file mode 100644 index 0000000..178a5b8 --- /dev/null +++ b/app/tencent/controller/Index.php @@ -0,0 +1,75 @@ +userinfo['LoginName']; + $userid = $this->userinfo['UserId']; + $data = $_POST; + $agreement_model = new AgreementModel; + + $agreement_data = [ + 'user_id' => $userid, + 'username' => $username, + 'describe' => $data['describe'], + ]; + + $xieyi = $_FILES['xieyi']; + + $size_limit = 30 * 1024 * 1024; + if ($xieyi['size']>$size_limit) { + echo json_encode(['code' => -1,'msg'=>'文件过大,仅限30M']); + die; + } + + $auth = new Auth($this->accessKey, $this->secretKey); + // 初始化 UploadManager 对象并进行文件的上传。 + $uploadMgr = new UploadManager(); + // 需要填写你的 Access Key 和 Secret Key + // 构建鉴权对象 + // 生成上传 Token + $token = $auth->uploadToken($this->bucket); + // 要上传文件的本地路径 + $xieyi_filePath = $xieyi['tmp_name']; + // 上传到存储后保存的文件名 + $xieyi_key = $username.'-'.time().'.png'; + if (isset($_FILES['yewu'])){ + $yewu = $_FILES['yewu']; + if ($yewu['size']>$size_limit) { + echo json_encode(['code' => -1,'msg'=>'文件过大,仅限30M']); + die; + } + // 要上传文件的本地路径 + $filePath = $yewu['tmp_name']; + // 上传到存储后保存的文件名 + $yewu_key = $username.'-'.time().'.mp4'; + // 调用 UploadManager 的 putFile 方法进行文件的上传。 + list($ret, $err) = $uploadMgr->putFile($token, $yewu_key, $filePath, null, 'application/octet-stream', true, null, 'v2'); + $agreement_data['yewu'] = 'http://zip.juip.com/'.$yewu_key; + } + + // 调用 UploadManager 的 putFile 方法进行文件的上传。 + list($ret, $err) = $uploadMgr->putFile($token, $xieyi_key, $xieyi_filePath, null, 'application/octet-stream', true, null, 'v2'); + $agreement_data['xieyi'] = 'http://zip.juip.com/'.$xieyi_key; + + $agreement_model->add($agreement_data); + + if ($err !== null) { + echo json_encode(['code' => -1,'msg'=>'上传失败']); + } else { + echo json_encode(['code' => 1,'msg'=>'上传成功']); + } + } +} \ No newline at end of file diff --git a/app/tencent/model/Agreement.php b/app/tencent/model/Agreement.php new file mode 100644 index 0000000..dbfebf0 --- /dev/null +++ b/app/tencent/model/Agreement.php @@ -0,0 +1,9 @@ +=5.3.3" + }, + "require-dev": { + "paragonie/random_compat": ">=2", + "phpunit/phpunit": "^4.8 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4", + "squizlabs/php_codesniffer": "^2.3 || ~3.6" + }, + "type": "library", + "autoload": { + "files": [ + "src/Qiniu/functions.php", + "src/Qiniu/Http/Middleware/Middleware.php" + ], + "psr-4": { + "Qiniu\\": "src/Qiniu" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Qiniu", + "email": "sdk@qiniu.com", + "homepage": "http://www.qiniu.com" + } + ], + "description": "Qiniu Resource (Cloud) Storage SDK for PHP", + "homepage": "http://developer.qiniu.com/", + "keywords": [ + "cloud", + "qiniu", + "sdk", + "storage" + ], + "support": { + "issues": "https://github.com/qiniu/php-sdk/issues", + "source": "https://github.com/qiniu/php-sdk/tree/v7.12.0" + }, + "time": "2023-12-25T08:30:40+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.0.0" +} diff --git a/fastphp/base/Controller.php b/fastphp/base/Controller.php index 021326c..5796bb1 100644 --- a/fastphp/base/Controller.php +++ b/fastphp/base/Controller.php @@ -1,12 +1,4 @@