PHP将图片流存为图片文件

//网签生成图片
        if (empty($data['signature'])) {
            return $result = ['code' => 0, 'msg' => '请签名后再提交!'];
        }

        //将图片流写入图片文件
        $file_path = ROOT_PATH.'public_html/uploads/signature';
        if (!file_exists($file_path)){
            mkdir($file_path);
        }
        $file_name = $this->c_user_id.'.png';
        $file = $file_path . '/' . $file_name;
        if (file_exists($file)) {
            unlink($file);
        }

        $image = file_get_contents ( $data['signature']);
        if (@$fp = fopen ( $file, 'w+' )) {
            fwrite ( $fp, $image );
            fclose ( $fp );
        }

 

posted @ 2021-09-15 08:24  Strive-count  阅读(670)  评论(0编辑  收藏  举报