header('Access-Control-Allow-Origin: *');
$post = $this->request->post();
//.转义
$post['content']= htmlspecialchars_decode($post['content']);
//获取字符串中的图片链接
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern,$post['content'],$match);

foreach ($match['1'] as $k=>$v)
{
    //转为base64
    $post['content']=str_replace($v,$this->base64EncodeImage($v), $post['content']);
}
//去除换行空格
$post['content'] = str_replace(PHP_EOL, '',$post['content']);

标签: none

添加新评论