时间:2021-07-01 10:21:17 帮助过:28人阅读
public function qiniu()
{
$setting=C('UPLOAD_SITEIMG_QINIU');
$Upload = new \Think\Upload($setting);
// dump($Upload);
$info = $Upload->upload();//上传成功
$url = $info['file']['url'];
dump($url);
$aaa = str_replace('http://<空间名字>.qiniudn.com', 'http://7xkd4t.com1.z0.glb.clouddn.com/', $url);
dump($aaa);
echo Qiniu_Sign($url);
dump($info);
}
调用的方法
function Qiniu_Encode($str) // URLSafeBase64Encode
{
$find = array('+', '/');
$replace = array('-', '_');
return str_replace($find, $replace, base64_encode($str));
}
function Qiniu_Sign($url) {//$info里面的url
$setting = C ( 'UPLOAD_SITEIMG_QINIU' );
$duetime = NOW_TIME + 86400;//下载凭证有效时间
$DownloadUrl = $url . '?e=' . $duetime;
$Sign = hash_hmac ( 'sha1', $DownloadUrl, $setting ["driverConfig"] ["secrectKey"], true );
$EncodedSign = Qiniu_Encode ( $Sign );
$Token = $setting["driverConfig"]["accessKey"] . ':' . $EncodedSign;
$RealDownloadUrl = $DownloadUrl . '&token=' . $Token;
return $RealDownloadUrl;
}
浏览器访问
{
"error": "no such entry"
}
求大神指点 这是什么情况 ???
控制器
public function qiniu()
{
$setting=C('UPLOAD_SITEIMG_QINIU');
$Upload = new \Think\Upload($setting);
// dump($Upload);
$info = $Upload->upload();//上传成功
$url = $info['file']['url'];
dump($url);
$aaa = str_replace('http://<空间名字>.qiniudn.com', 'http://7xkd4t.com1.z0.glb.clouddn.com/', $url);
dump($aaa);
echo Qiniu_Sign($url);
dump($info);
}
调用的方法
function Qiniu_Encode($str) // URLSafeBase64Encode
{
$find = array('+', '/');
$replace = array('-', '_');
return str_replace($find, $replace, base64_encode($str));
}
function Qiniu_Sign($url) {//$info里面的url
$setting = C ( 'UPLOAD_SITEIMG_QINIU' );
$duetime = NOW_TIME + 86400;//下载凭证有效时间
$DownloadUrl = $url . '?e=' . $duetime;
$Sign = hash_hmac ( 'sha1', $DownloadUrl, $setting ["driverConfig"] ["secrectKey"], true );
$EncodedSign = Qiniu_Encode ( $Sign );
$Token = $setting["driverConfig"]["accessKey"] . ':' . $EncodedSign;
$RealDownloadUrl = $DownloadUrl . '&token=' . $Token;
return $RealDownloadUrl;
}
浏览器访问
{
"error": "no such entry"
}
求大神指点 这是什么情况 ???