1.base64
public function uploadimgfrombase64() { $param = $this->request->param(); if ($param['img_size'] > 0) { preg_match('/^(data:\s*image\/(\w+);base64,)/', $param['img'], $result); $ext = $result[2]; $filename = '/upload/wxsharepic/' . time() . getorderid() . '.' . $ext; $fp2 = @fopen(CMF_ROOT . $filename, "a"); fwrite($fp2, base64_decode(str_replace($result[1], '', $param['img']))); //向当前目录写入图片文件,并重新命名 fclose($fp2); $this->success('上传成功', '', $filename); } else { $this->error('上传失败'); } }
本文为看恩吧原创文章,转载无需和我联系,但请注明来自knsay.com