|
@@ -0,0 +1,56 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+|--------------------------------------------------------------------------
|
|
|
+| 查看图片的几个方法
|
|
|
+|--------------------------------------------------------------------------
|
|
|
+*/
|
|
|
+namespace Upload\Src;
|
|
|
+
|
|
|
+use Dever;
|
|
|
+Dever::apply('sdk/qiniu', 'upload');
|
|
|
+
|
|
|
+class Qiniu
|
|
|
+{
|
|
|
+ public function callback()
|
|
|
+ {
|
|
|
+ $body = file_get_contents('php://input');
|
|
|
+ file_put_contents(Dever::data() . "test.txt",$body);
|
|
|
+ $body = json_decode($body, true);
|
|
|
+ $fname = $body['filename'];
|
|
|
+ $fkey = $body['fkey'];
|
|
|
+ $filesize = $body['filesize'];
|
|
|
+ $width = $body['width'];
|
|
|
+ $height = $body['height'];
|
|
|
+ $arr=array("date"=>"test");
|
|
|
+ echo json_encode($arr);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function token()
|
|
|
+ {
|
|
|
+ $key = Dever::input('key');
|
|
|
+ $upload = Dever::db('upload/upload')->one($key);
|
|
|
+ if (!$upload) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $config = Dever::db('upload/yun')->one($upload['yun']);
|
|
|
+ $accessKey = $config['appkey'];
|
|
|
+ $secretKey = $config['appsecret'];
|
|
|
+ $host = $config['host'];
|
|
|
+ $auth = new \Qiniu\Auth($accessKey, $secretKey);
|
|
|
+ $bucket = $upload['bucket'];
|
|
|
+
|
|
|
+ $policy = array(
|
|
|
+ 'callbackUrl' => Dever::url('qiniu.callback', 'upload'),
|
|
|
+ 'callbackBody' => 'filename=$(fname)&fkey=$(key)&filesize=$(fsize)&width=$(imageInfo.width)&height=$(imageInfo.height)'
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+ $token = $auth->uploadToken($bucket, null, 3600);
|
|
|
+
|
|
|
+ $domain = 'http://up-z1.qiniup.com/';
|
|
|
+ $ret = array('uptoken' => $token, 'domain' => $domain, 'host' => $config['host']);
|
|
|
+
|
|
|
+ echo json_encode($ret);die;
|
|
|
+ }
|
|
|
+}
|