use OSS\Core\OssException;
use OSS\OssClient;
public function insert()
{
$file = request()->file('image');
$name=$file->getPathname();
// print_r($name);die();
//apikey
$apikey="BBmaz8XU1rKEHChQSqlsdCvG";
//SecretKey
$SecretKey="kmta1oDReXWWh2WOOhRlukL2PkcaIZGE";
//获取url
$url= "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={$apikey}&client_secret={$SecretKey}";
//获取到token;
$info= curlGet($url);
$token=$info['access_token'];
$url = 'https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined?access_token=' . $token;
$img = file_get_contents($name);
$img = base64_encode($img);
$bodys = array(
'image' => $img
);
ThinkPHP6 阿里云图片上传
最新推荐文章于 2025-01-17 21:24:24 发布
本文介绍了如何在ThinkPHP6框架下结合阿里云服务进行图片上传操作。通过调用阿里云的API,利用PHP的文件上传功能,配合Postman工具进行接口测试,详细阐述了整个流程和关键代码实现。

最低0.47元/天 解锁文章
640

被折叠的 条评论
为什么被折叠?



