保存图片的字段 数据类型为:blob
img.php
<?php $filename = "Admin/Upload/3025994.jpg";// 读取文件$fp = fopen($filename,"rb");$data = addslashes(fread($fp,filesize($filename)));fclose($fp);// 操作MYSQL$conn=mysql_connect("localhost","root","admin");@mysql_select_db("mytest",$conn);// 存入数据库$query="insert into pic values (5,'$data')";$result=mysql_query($query);$id=mysql_insert_id(); //读取数据$query="select * from pic where picid=5 limit 0,1";$result=mysql_query($query);$row=mysql_fetch_array($result);$data = $row["Pic"];// 显示文件header("Content-type: image/*");echo $data;?>
在其他页面如下形式引用: