The cut piece is in data:image/xxx;base64 format, how to pick up the back end of php?

https://github.com/Foliotek/C.

I found this package of clips
, but the address of the clipped web

how can I php accept this format?
what else does js need to process before it can be sent to php??
all I know now is that this base64 will show up here

clipboard.png


https://github.com/renyanwei/.


$types = empty ($types)? Array ('jpg',' gif', 'png',' jpeg'): $types;

    $img = str_replace(array('_','-'), array('/','+'), $request->input('image'));
    $b64img = substr($img, 0,100);
    if(preg_match('/^(data:\s*image\/(\w+);base64,)/', $b64img, $matches)){
        $type = $matches[2];
        if(!in_array($type, $types)){
            return array('type'=>'0','msg'=>'','url'=>'');
        }
        $img = str_replace($matches[1], '', $img);
        $img = base64_decode($img);
        $photo = 'upload/links/'.md5(date('YmdHis').rand(1000, 9999)).'.'.$type;
        file_put_contents(env('IMAGE_URL').'/'.$photo, $img);
        $thumbnail=self::resizeImage('0.5',$photo,'thumbnail');
        $min      =self::resizeImage('0.2',$photo,'min');
        return ['type'=>'1','url'=>'/'.$photo,'thumbnail'=>$thumbnail,'min'=>$min];

    }
Menu