正在显示
1 个修改的文件
包含
21 行增加
和
2 行删除
| @@ -171,7 +171,7 @@ class CosService | @@ -171,7 +171,7 @@ class CosService | ||
| 171 | public function addFieldImage($cdnUrl = '',$data = [],$is_image = false){ | 171 | public function addFieldImage($cdnUrl = '',$data = [],$is_image = false){ |
| 172 | if($is_image){ | 172 | if($is_image){ |
| 173 | $param = [ | 173 | $param = [ |
| 174 | - 'image/'.urlencode(base64_encode("{$data['image']}")),//文字水印名称 | 174 | + 'image/'.urlSafeBase64Encode($data['image']),//文字水印名称 |
| 175 | $data['position'] ?? 'gravity/SouthEast', | 175 | $data['position'] ?? 'gravity/SouthEast', |
| 176 | $data['dx'] ?? 'dx/10/dy/10', | 176 | $data['dx'] ?? 'dx/10/dy/10', |
| 177 | $data['font'] ?? 'font/5bCP6aOe',//默认宋体 | 177 | $data['font'] ?? 'font/5bCP6aOe',//默认宋体 |
| @@ -181,7 +181,7 @@ class CosService | @@ -181,7 +181,7 @@ class CosService | ||
| 181 | $cdnUrl = $cdnUrl.'?imageMogr2/watermark/1/'.implode('/',$param); | 181 | $cdnUrl = $cdnUrl.'?imageMogr2/watermark/1/'.implode('/',$param); |
| 182 | }else{ | 182 | }else{ |
| 183 | $param = [ | 183 | $param = [ |
| 184 | - 'text/'.urlencode(base64_encode("{$data['characters']}")),//文字水印名称 | 184 | + 'text/'.urlSafeBase64Encode($data['characters']),//文字水印名称 |
| 185 | $data['position'] ?? 'gravity/SouthEast', | 185 | $data['position'] ?? 'gravity/SouthEast', |
| 186 | $data['dx'] ?? 'dx/10/dy/10', | 186 | $data['dx'] ?? 'dx/10/dy/10', |
| 187 | $data['font'] ?? 'font/5bCP6aOe',//默认宋体 | 187 | $data['font'] ?? 'font/5bCP6aOe',//默认宋体 |
| @@ -192,4 +192,23 @@ class CosService | @@ -192,4 +192,23 @@ class CosService | ||
| 192 | } | 192 | } |
| 193 | return $cdnUrl; | 193 | return $cdnUrl; |
| 194 | } | 194 | } |
| 195 | + | ||
| 196 | + /** | ||
| 197 | + * @remark :腾讯云安全的base64 | ||
| 198 | + * @name :urlSafeBase64Encode | ||
| 199 | + * @author :lyh | ||
| 200 | + * @method :post | ||
| 201 | + * @time :2024/8/19 14:21 | ||
| 202 | + */ | ||
| 203 | + public function urlSafeBase64Encode($data) { | ||
| 204 | + // 1. 使用标准的 BASE64 编码 | ||
| 205 | + $base64 = base64_encode($data); | ||
| 206 | + // 2. 将加号(+)替换成连接号(-) | ||
| 207 | + $base64 = str_replace('+', '-', $base64); | ||
| 208 | + // 3. 将正斜线(/)替换成下划线(_) | ||
| 209 | + $base64 = str_replace('/', '_', $base64); | ||
| 210 | + // 4. 去掉末尾的等号(=) | ||
| 211 | + $base64 = rtrim($base64, '='); | ||
| 212 | + return $base64; | ||
| 213 | + } | ||
| 195 | } | 214 | } |
-
请 注册 或 登录 后发表评论