<?php
//insertimage.php
//上传图片插入数据库
if (isset($HTTP_POST_VARS["Submit2"]))
{
$pos = $HTTP_POST_VARS["pos"];
$filename = $HTTP_POST_FILES["file"]["tmp_name"];
$size = $HTTP_POST_FILES["file"]["size"];
if ($size<=204800)
{
$img = addslashes(fread(fopen($filename,"r"),$size));
$link=mysql_connect("127.0.0.1","user","psw") or die("Could not connect: ".mysql_error());
mysql_select_db("action",$link);
$sql = "update actionSeek set pos='$pos',img='$img' where ZGMName='".$_SESSION["ZGMName"]."'";
if ($result = mysql_query($sql))
print("<script>alert('上传成功');</script>");
else
print("<script>alert('上传失败')</script>");
}
}
?>
<?php
//showimage.php
//显示数据库里的图片
session_start();
$link=mysql_connect("127.0.0.1","user","pwd") or die("Could not connect: ".mysql_error());
mysql_select_db("action",$link);
$sql = "select img from actionSeek where ZGMName='".$_SESSION["ZGMName"]."'";
$result = mysql_query($sql);
if ($row = mysql_fetch_array($result))
{
print ($row["img"]);
}
?>