日期:2014-05-17 浏览次数:20649 次
<?php
require_once("conn.php");
$cover=$_POST['cover'];
if($_POST['sub']){
header("Content-Type:image/jpeg",true);
//以只读的方式打开二进制文件
$fp=fopen($cover,"rb");
$image=addslashes(fread($fp,filesize($cover)));
$sql1="insert into phototest (id,photo) values('','$image')";
$insert=mysql_query($sql1,$conn);
$sql2="select * from phototest";
$select=mysql_query($sql2,$conn);
//$result=mysql_fetch_array($select); echo $result[1];//用一条语句能输出一张图片
?> <table width="80%" height="80%" border="1"> <?php
while($result=mysql_fetch_array($select)){
//echo stripslashes($result['photo']); //stripslashes()去除反斜杠
?>
<tr height="400">
<td> <?php echo $result['photo']?> </td>
</tr>
<?php
}
?> </table> <?php
//关闭文件
fclose($fp);
?>