//上传到oss服务器上的图片function addossimg($image){ //这里的$image是指$_FILES[‘key‘]的值 $url=‘http://ceshimain.oss-cn-hangzhou.aliyuncs.com‘;//远程oss的链接 这个是appid seret这是 $success = new \Api\Service\OSS\OssClient(‘7wDuicrZeSm3LidN‘,‘5NMNsAF0mT1xfU19e3gviuBI8YKQBP‘,$url); $ext = strtolower(trim(substr($image[‘name‘], strrpos($image[‘name‘], ‘.‘)), ‘.‘)); $image[‘name‘] = md5(time() . uniqid()); 文件名 $object = ‘luntai/‘.$image[‘name‘].‘.‘.$ext; $filePath = $image[‘tmp_name‘]; try { bucket $success->uploadFile(‘ceshimain‘,$object,$filePath); 文件名 return $url.‘/luntai/‘.$image[‘name‘].‘.‘.$ext;// return ‘1001‘; } catch (Exception $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return ‘1002‘; }}
时间: 2024-11-07 18:15:26