求教!请详细谈一下在MYSQL中如何存取图片? http://expert.csdn.net/Expert/topic/1113/1113409.xml?temp=.4967615 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $filename = "test.jpg";// 读取文件$fp = fopen($filename,"rb");$picture = fread($fp,filesize($filename));$picture = base64_encode($picture);fclose($fp);// 操作MYSQL$conn=mysql_connect("localhost","root","");@mysql_select_db("test",$conn);// 存入数据库$query="insert into pic (filename,picture) values ('$filename','$picture')";$result=mysql_query($query);$id=mysql_insert_id();// 读取数据$query="select * from pic where id='$id'";$result=mysql_query($query);$row=mysql_fetch_array($result);$data = base64_decode($row[picture]);// 显示文件header("Content-type: image/jpeg");echo $data; http://www.google.com/search?q=%E5%9B%BE%E7%89%87+%E6%95%B0%E6%8D%AE%E5%BA%93+MySQL&ie=UTF-8&oe=UTF-8&hl=zh-CN&btnG=Google%E6%90%9C%E7%B4%A2&lr= public方法访问的问题。 smarty安装 $str.="<option value={$rs[0]} {$sel}>{$rs[1]}</a>"不明白 第十四轮散分宣传 php如何获取绝对路径比如http://127.0.0.1:8080/lc 数据查询优化问题 为什么插入操作不执行呢? 菜鸟问题:ZEROFILL是什么意思? 如何获取图片的尺寸大小? 再提文件锁定。 MySQL语句用ORDER BY排序后怎样提取第N到N+10条记录? Oracle clob 字段处理问题
// 读取文件
$fp = fopen($filename,"rb");
$picture = fread($fp,filesize($filename));
$picture = base64_encode($picture);
fclose($fp);
// 操作MYSQL
$conn=mysql_connect("localhost","root","");
@mysql_select_db("test",$conn);
// 存入数据库
$query="insert into pic (filename,picture) values ('$filename','$picture')";
$result=mysql_query($query);
$id=mysql_insert_id();
// 读取数据
$query="select * from pic where id='$id'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$data = base64_decode($row[picture]);
// 显示文件
header("Content-type: image/jpeg");
echo $data;