https://github.com/Foliotek/C...
我找到這個裁切圖片的套件但是裁切出來的圖片網址變成
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMwAAADMCAYAAAA/IkzyAAAgAElEQV......">
這種格式,我php要怎麼接收?js還需要怎麼處理才能送到php?我現在只知道這個 base64會在這出現
2 回答
茅侃侃
TA贡献1842条经验 获得超21个赞
$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];
}
- 2 回答
- 0 关注
- 467 浏览
添加回答
举报
0/150
提交
取消