首页 > php与数据库 > 显示保存在mysql数据库中图片代码

显示保存在mysql数据库中图片代码

<?php
header( "content-type:image/gif "); 
include( "../inc/conn.php教程 "); 
mysql_select_db( "ce_cdprog ",$db); 
$rs=mysql_query( "select   *   from   pic   where   id=$id "); 
$row=mysql_fetch_array($rs); 
echo   $row[ "mc "];


//方法二

<?php
while (($row=$results->fetch_assoc()) !==null) 
{
    header( "Content-type:{$row['image_type']}");
    echo $row['image'];
    imagedestroy($img);
}
<?php
//图片保存到数据库
move_uploaded_file($_FILES['imagefile']['tmp_name'],"latest.img"); 
$instr = fopen("latest.img","rb"); 
$image = addslashes(fread($instr,filesize("latest.img"))); 
if (strlen($instr) < 149000) { 
  mysql_query ("insert into pix (title, imgdata) values ("". 
  $_REQUEST[whatsit]. 
  "", "". 
  $image. 
  "")"); 
} else { 
  $errmsg = "Too large!"; 
}


文章地址:http://www.phprm.com/database/33461.html

转载随意^^请带上本文地址!

标签:none

发表留言