$str = str_replace(' ', '+', $str); //替换空字符串为+
$str = str_replace('
', '',$str); //置空换行符
$str = str_replace(' ', '',$str);
$str = str_replace('
', '',$str);
$str = stripslashes($str); //过虑转义符
$img = base64_decode($str); //解码
file_put_contents(ROOT_PATH . 'public/uploads/' . $saveName,$img); //保存图片