🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
```php public function base64_image_content($base64_image_content,$path){ //匹配出图片的格式 if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)){ $type = $result[2]; //$ff=date('Y-m-d',time()); $new_file = $path."/lunbo/"; if(!file_exists($new_file)){ //检查是否有该文件夹,如果没有就创建,并给予最高权限 mkdir($new_file, 0700); } $picname=mt_rand(0,99).time().".{$type}"; $new_file = $new_file.$picname; if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_image_content)))){ return "/Uploads/lunbo/".$picname; }else{ return false; } }else{ return false; } } // 调用 $data['pic'] = $this->base64_image_content($_POST['thumb_url'],'./Uploads'); ```