#1 slyjit
require_once __DIR__ . '/qiniusdk/autoload.php';这是我上传图片到七牛云存储的代码,直接访问是可以的;然后我想把这段代码放到SP框架来使用:
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;
$accessKey = '5aa';
$secretKey = 'Hdd';
$auth = new Auth($accessKey, $secretKey);
$bucket = 'yue';
$token = $auth->uploadToken($bucket);
$uploadMgr = new UploadManager();
$filePath = $_FILES['file']['tmp_name'];
$key = 'php-logo.png';
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
echo "\n====> putFile result: \n";
if ($err !== null) {
var_dump($err);
} else {
var_dump($ret);
}
function photoups(){在使用 use Qiniu\Auth; 时候,Parse error: syntax error, unexpected T_USE in controller/main.php on line 20
import('./SpeedPHP/Extensions/qiniusdk/autoload.php');
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;
$accessKey = '5dd';
$secretKey = 'Hrcc';
$auth = spClass('Auth',array($accessKey,$secretKey));
$bucket = 'yue';
$token = $auth->uploadToken($bucket);
$uploadMgr = spClass('UploadManager');
$filePath = $_FILES['file']['tmp_name'];
$key = 'php-logo2.png';
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
echo "\n====> putFile result: \n";
if ($err !== null) {
var_dump($err);
} else {
var_dump($ret);
}
}
use Qiniu\Auth所在行就是20行;不知到问题出在何处?
2015-10-23 17:31:13