//读取图片文件php的数据库图片格式 , 转换成base64编码格式
$image_file = './image123.jpg';
$image_info = getimagesize($image_file);
$base64_image_content = "data:{$image_info['mime']};base64," . chunk_split(base64_encode(file_get_contents($image_file)));
// $base64_image_content 输入到数据库
//保存base64字符串为图片
//匹配出图片php的数据库图片格式的格式
if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)){
$type = $result[2];
$new_file = "./test.{$type}";
if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_image_content)))){
echo '新文件保存成功php的数据库图片格式:', $new_file;
}
}
?
img src="http://img.readke.com/231129/1Z6134138-0.jpg echo $base64_image_content;?" /
【php的数据库图片格式 php图片上传数据库】php的数据库图片格式的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于php图片上传数据库、php的数据库图片格式的信息别忘了在本站进行查找喔 。
推荐阅读
- 解谜游戏核心玩法,解谜游戏核心玩法有哪些
- 鸿蒙系统能兼容windows游戏吗,鸿蒙系统可以玩电脑游戏吗
- jquery触发input,jquery触发点击事件click
- 怎样做淘宝视频直播带货,想要做淘宝直播怎么做
- PHP海量数据存储 php的数据是怎么样存在内存中的
- python中计算四分位点的函数的简单介绍
- moba即时对战游戏,对战平台moba
- 益智游戏连线游戏教案,连线游戏幼儿
- vb.net计算时间间隔的简单介绍