1 Star 0 Fork 6

云海观澜/adam_qiniu

forked from szwldev/adam_qiniu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
upload.php 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
szwldev 提交于 2019-03-18 10:25 . adam_qiniu
<?php
!defined('DEBUG') AND exit('Access Denied.');
function uploadfile($path){
require("Qiniu/autoload.php");
//require 'plugin/gmchina_xiuno_editormd/upload/qiniu/Qiniu/src/Qiniu/Auth.php';
$config = include("config.php");
$mimetype=explode(",", str_replace(array(",",';',';'," "),",",$config['mimetype']));
$ext= pathinfo($path, PATHINFO_EXTENSION);
if(in_array($ext, $mimetype) == false) {
return false;
}else{
$key =md5(date('YmdHis') . rand(0, 9999)) . '.' . $ext;
$accessKey = $config['accessKey'];
$secretKey = $config['secretKey'];
$auth = new Qiniu\Auth($accessKey, $secretKey);
$bucket = $config['bucket'];
$domain = $config['cdnurl'];
$token = $auth->uploadToken($bucket);
$uploadMgr = new Qiniu\Storage\UploadManager();
list($ret, $err) = $uploadMgr->putFile($token, $key, $path);
if ($err !== null) {
return false;
}else {
return $domain.'/'.$ret['key'];
}
}
}
?>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/vfount/adam_qiniu.git
[email protected]:vfount/adam_qiniu.git
vfount
adam_qiniu
adam_qiniu
master

搜索帮助