tp3.2 php sdk上传七牛云

//获取上传token
Vendor('sdk.autoload');
$accessKey='********';
$secretKey='*******';
$auth=new \Qiniu\Auth($accessKey,$secretKey);
$token=$auth->uploadToken('***');
//此路径为绝对路径
$filePath =$path;
// 上传到七牛后保存的文件名
$key = 'ceshi.txt';
$uploadMgr = new \Qiniu\Storage\UploadManager();
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
if ($err !== null) {
$res['content']=$err;
$res['error'] = 201;
} 
else 
{
 //进行入库
 $res['content']='成功';
 $res['error']= 200;
}
posted @ 2018-04-10 17:41  phpwyl  阅读(847)  评论(1编辑  收藏  举报