基本的存图片和取图片过程 存图片的字段设置成_bin 二进制方式存储.读出后可直接ECHO.但在echo 前需用header送出MIME头. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 数据库字段设置成二进制形式,读取文件并写入图片文件到数据库。读取时取出数据,然后设置头标位图片格式的,然后echo输出刚才读取数据库的内容。 假设已经建好类似的这样一个表:create table pic(id smallint unsigned,pic mediumblob,primary key(id));<?php header("Content-Type: image/jpeg"); $pic='F:\\program\\img\\140.jpg';//要插入的图片 $fb= base64_encode(file_get_contents($pic));//为防止特殊字符无法插入,先base64编码 $db= mysql_pconnect("localhost","root",""); mysql_select_db("test",$db);//pic 在test 里 mysql_query("insert into pic values(5,'$fb');") or die(mysql_error()); $results= mysql_query("select * from pic where id=5;"); $row= mysql_fetch_row($results); echo base64_decode($row[1]);?> php 乱码问题 为自己企业用户郡发资料问题. 一小段Apache日志 我选择一个头像,然后在文本框自动加上这个头像的名称 如何设计??? 高分求教,请问php5中如何将时间插入orcal中,在线等! 分不够了,但是还望赐教!如何在自己的商务网站上集成paypal的接口? 谁碰到过Object not found!错误,急急急! 对于数字型的字段,有什么通配符可用吗? FCKeditor1.2.4随风汉化版(GPL协议发放) -- 作者:随风而逝 如何设置sendmai_from才能发送邮件啊,要发送邮件该怎么设置?? php5 网页500错误 PHP SOAP
读取时取出数据,然后设置头标位图片格式的,然后echo输出刚才读取数据库的内容。
create table pic(
id smallint unsigned,
pic mediumblob,
primary key(id));
<?php
header("Content-Type: image/jpeg");
$pic='F:\\program\\img\\140.jpg';//要插入的图片
$fb= base64_encode(file_get_contents($pic));//为防止特殊字符无法插入,先base64编码 $db= mysql_pconnect("localhost","root","");
mysql_select_db("test",$db);//pic 在test 里
mysql_query("insert into pic values(5,'$fb');") or die(mysql_error());
$results= mysql_query("select * from pic where id=5;");
$row= mysql_fetch_row($results);
echo base64_decode($row[1]);
?>