from 标签少了属性 enctype="multipart/form-data"
$sql="SELECT * FROM $my_type WHERE id='$id'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"1\" bordercolordark=\"#ffffff\" bordercolorlight=\"#0000ff\" width=\"950\">";
echo "<form method=post action=e_type.php?id=".$id." onsubmit=\"return check(this)\">";
echo "<tr><td colspan=\"2\" align=\"center\">类别:<font color=\"#ff0000\">".$row[name]."</font>的内容</td></tr>";
echo "<tr>";
echo "<td>类别编号:</td><td>".$row[id]."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>类别名称:</td><td><input type=text name=name value=".$row[name]."></td>";
echo "</tr>";
echo "<tr>";
echo "<td>类别图片:</td><td><input type=file name=upfile value=".$row[img]."></td>";
echo "</tr>";
echo "<tr>";
echo "<td>类别介绍:</td><td><input type=text name=description value=".$row[description]."></td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"2\" align=\"center\"><input type=submit value=\"提交修改\"><input type=button value=\"放弃修改\" onclick=history.go(-1)></td>";
echo "</tr>";
echo "</form>";
echo "</table>";
}
else
{
$name=$_POST[name];
$description=$_POST[description];
$filepath="../../images/type/";
$way=$_FILES["upfile"]["name"];
$today=date("YmdHis"); //当前时间
$temp=explode(".",$way); //分割字符串取图片后缀名
$way=$filepath.$today.".".$temp[1]; //文件上传路径
$mysql_way="../images/type/".$today.".".$temp[1]; //存入数据库的链接,因为前台跟后台不在同一层,所以文件上传路径不等于存入数据库路径
if(!(move_uploaded_file($_FILES["upfile"]["tmp_name"],$way)))
{
echo "文件上传过程中出现错误!";
echo "<p>";
echo "<meta http-equiv=\"refresh\" content=\"1; url=e_type.php\">";
echo "更新类别信息:".$id."失败<p>";
echo "两秒后返回";
}
else
{
$sql="UPDATE $my_type SET name='$name',img='$mysql_way',description='$description' WHERE id='$id'";
$re=mysql_query($sql,$my_conn) or die(mysql_error());
if($re)
{
echo "<meta http-equiv=\"refresh\" content=\"1; url=e_type.php\">";
echo "成功更新类别介绍信息:".$id."<p>";
echo "两秒后返回";
}
}