分享 php 将图片转为数据流入库还原操作
程序员文章站
2022-05-01 18:30:13
...
?php $Picture = './all-index-right-pic0.jpg'; If($Picture != none) { $PSize = filesize($Picture); $mysqlPicture = fread(fopen($Picture, r), $PSize); //可将 $mysqlPicture 存入数据库,当然字段的是2进制的 //读取出来的还原操作,和验证码的实现机
$Picture = './all-index-right-pic0.jpg';
If($Picture != "none") {
$PSize = filesize($Picture);
$mysqlPicture = fread(fopen($Picture, "r"), $PSize);
//可将 $mysqlPicture 存入数据库,当然字段的是2进制的
//读取出来似的还原操作,和验证码的实现机制差球不多啊
Header( "Content-type: image/gif");
echo $mysqlPicture;
}else {
echo"You did not upload any picture";
}
?>