上传协议书
This commit is contained in:
75
app/tencent/controller/Index.php
Normal file
75
app/tencent/controller/Index.php
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\tencent\controller;
|
||||||
|
|
||||||
|
use fastphp\base\Controller;
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Storage\UploadManager;
|
||||||
|
use app\tencent\model\Agreement as AgreementModel;
|
||||||
|
|
||||||
|
|
||||||
|
class Index extends Controller
|
||||||
|
{
|
||||||
|
private $accessKey = 'AfRhvJoAKL24ftGcHMor1WwSpVdular7L7X97JNY';
|
||||||
|
private $secretKey = 'OyyU-6M45oDZAlVsf8fH0RFALGxTNHAT-yR6cmtU';
|
||||||
|
private $bucket = 'zip9';
|
||||||
|
public function upload()
|
||||||
|
{
|
||||||
|
$username = $this->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'=>'上传成功']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
app/tencent/model/Agreement.php
Normal file
9
app/tencent/model/Agreement.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
namespace app\tencent\model;
|
||||||
|
|
||||||
|
use fastphp\base\Model;
|
||||||
|
|
||||||
|
class Agreement extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'use_agreement';
|
||||||
|
}
|
||||||
5
composer.json
Normal file
5
composer.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"require": {
|
||||||
|
"qiniu/php-sdk": "^7.12"
|
||||||
|
}
|
||||||
|
}
|
||||||
152
composer.lock
generated
Normal file
152
composer.lock
generated
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "4ad6b863e78d2a5bd92efb01705d74d8",
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "myclabs/php-enum",
|
||||||
|
"version": "1.8.4",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/myclabs/php-enum.git",
|
||||||
|
"reference": "a867478eae49c9f59ece437ae7f9506bfaa27483"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/a867478eae49c9f59ece437ae7f9506bfaa27483",
|
||||||
|
"reference": "a867478eae49c9f59ece437ae7f9506bfaa27483",
|
||||||
|
"shasum": "",
|
||||||
|
"mirrors": [
|
||||||
|
{
|
||||||
|
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||||
|
"preferred": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
|
"php": "^7.3 || ^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^9.5",
|
||||||
|
"squizlabs/php_codesniffer": "1.*",
|
||||||
|
"vimeo/psalm": "^4.6.2"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"MyCLabs\\Enum\\": "src/"
|
||||||
|
},
|
||||||
|
"classmap": [
|
||||||
|
"stubs/Stringable.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP Enum contributors",
|
||||||
|
"homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP Enum implementation",
|
||||||
|
"homepage": "http://github.com/myclabs/php-enum",
|
||||||
|
"keywords": [
|
||||||
|
"enum"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/myclabs/php-enum/issues",
|
||||||
|
"source": "https://github.com/myclabs/php-enum/tree/1.8.4"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/mnapoli",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2022-08-04T09:53:51+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "qiniu/php-sdk",
|
||||||
|
"version": "v7.12.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/qiniu/php-sdk.git",
|
||||||
|
"reference": "96971af3cc6151b32e4a9d61001e126624100538"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/qiniu/php-sdk/zipball/96971af3cc6151b32e4a9d61001e126624100538",
|
||||||
|
"reference": "96971af3cc6151b32e4a9d61001e126624100538",
|
||||||
|
"shasum": "",
|
||||||
|
"mirrors": [
|
||||||
|
{
|
||||||
|
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||||
|
"preferred": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"myclabs/php-enum": "~1.5.2 || ~1.6.6 || ~1.7.7 || ~1.8.4",
|
||||||
|
"php": ">=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"
|
||||||
|
}
|
||||||
@@ -1,12 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
* @Descripttion:
|
|
||||||
* @version:
|
|
||||||
* @Author: kangkang
|
|
||||||
* @Date: 2020-09-30 17:32:46
|
|
||||||
* @LastEditors: “wanyongkang” “937888580@qq.com”
|
|
||||||
* @LastEditTime: 2024-02-18 11:30:43
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace fastphp\base;
|
namespace fastphp\base;
|
||||||
|
|
||||||
@@ -22,7 +14,7 @@ class Controller
|
|||||||
//初始化属性,实例化对应模型
|
//初始化属性,实例化对应模型
|
||||||
public function __construct($controller,$action)
|
public function __construct($controller,$action)
|
||||||
{
|
{
|
||||||
$data = json_decode(file_get_contents("php://input"),true);
|
$data = empty(json_decode(file_get_contents("php://input"),true))?$_POST:json_decode(file_get_contents("php://input"),true);
|
||||||
$getPayload = false;
|
$getPayload = false;
|
||||||
if(isset($data['cookie'])){
|
if(isset($data['cookie'])){
|
||||||
$cookie = explode('; ',$data['cookie']);
|
$cookie = explode('; ',$data['cookie']);
|
||||||
|
|||||||
Reference in New Issue
Block a user