3 months ago

Unicode problem, output strange words when in chinese

Posted 3 months ago by kankai

Hi guys,

I'm using summernote editor post content and upload image to my website. But i found out unicode problem and save strange words to my db.


i suspect these code will affect to output but i'm not good with these


$dom = new \DomDocument();

$images = $dom->getElementsByTagName('img');

foreach($images as $k => $img){

            $data = $img->getAttribute('src');

            list($type, $data) = explode(';', $data);

            list(, $data)      = explode(',', $data);

            $data = base64_decode($data);

            $image_name= "/upload/" .time().$k.'.jpg';

            $path = public_path() . $image_name;

            file_put_contents($path, $data);


            $img->setAttribute('src', $image_name);


        $detail = $dom->saveHTML();

Please sign in or create an account to participate in this conversation.