<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>NetGreen——文件上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="main.css">
<script language="JavaScript">
{
function upload_check()
{
if(document.upload.id.value=="")
{
alert("用户名不能为空!");
document.upload.id.focus();
return false;
}
else if(document.upload.id.value.length>15)
{
alert("用户名长度过长!");document.upload.id.focus();
return false;
}
else if(document.login.upload.value.length<5)
{
alert("用户名长度过短!");document.upload.id.focus();
return false;
}
///////
if(document.upload.password.value=="")
{
alert("密码不能为空!");
document.upload.password.focus();
return false;
}
else if(document.upload.password.value.length>15)
{
alert("密码长度过长!");document.upload.password.focus();
return false;
}
else if(document.upload.password.value.length<5)
{
alert("密码长度过短!");document.upload.password.focus();
return false;
}
}
}
</script>
</head>
<body bgcolor="ffffff" >
<center>
<table width="80%" border="0" height="535">
<tr>
<td height="71" align="center" valign="middle"> <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#0099CC">
<tr>
<td width="19%" height="60" align="left" valign="bottom" bgcolor="#FFFFFF"><b><font size="4" color="#00cc66" ><img src="logo.gif" width="156" height="60"></font></b></td>
<td width="57%" align="left" valign="bottom" bgcolor="#FFFFFF"><img src="banner.gif" width="100%" height="60"></td>
<td width="24%" align="left" valign="bottom"> <table width="102%" height="60" border="1" cellpadding="0" cellspacing="0" bordercolor="#0099CC" bgcolor="#FFFFFF">
<tr>
<td width="50%" height="27" align="center">上 传</td>
<td width="50%" align="center">收藏本页</td>
</tr>
<tr>
<td height="21" align="center" bgcolor="#FFFFFF" > <a href="guestbook.php" target="_self">我要留言</a></td>
<td align="center">退出</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="31"><table width="100%" border="1" bordercolor="#00FF33">
<tr bgcolor="#00CC66">
<td width="12%" height="25" align="center"><a href="index.php" target="_self">首页</a></td>
<td width="12%" align="center" bgcolor="#00CC66"><a href="program.php" >编程起步</a></td>
<td width="12%" align="center"><a href="homemake.php" >网页制作</a></td>
<td width="12%" align="center" bgcolor="#00CC66"><a href="imageprocess.php" >图像处理</a></td>
<td width="12%" align="center" > <a href="hardware.php" >硬件动态</a></td>
<td width="12%" align="center"><a href="music.php" >在线音乐</a></td>
<td width="12%" align="center"><a href="comic.php" >动漫秀</a></td>
<td width="12%" align="center" bgcolor="#00CC66"> <a href="game.php" >酷热游戏</a></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" valign="top" nowrap><table width="100%" height="383" border="1" cellpadding="0" cellspacing="0" bordercolor="#0099CC">
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF"> <table width="96%" height="100%" border="1" bordercolor="#ccff66">
<tr align="left" valign="middle" bgcolor="#FFFFFF">
<td height="54"> 您现 在的位置:<a href="index.php" target="_self">首页</a>
-><font color="red">上传文件</font></td>
</tr>
<tr align="left" valign="middle" bgcolor="#FFFFFF">
<td height="317" align="center" valign="top"><table width="100%" border="0">
<tr>
<td width="78%" height="236" align="center" valign="middle">
<?
require("connect.inc");
if(empty($cmd))
{
$cmd="upload";
}
switch($cmd)
{
case "upload":
echo '<table width="80%" border="1">
<form name="upload" method="post" enctype="multipart/form-data"
action="upload.php?cmd=copy" onsubmit="return upload_check();">
<tr bgcolor="#FFFFFF">
<td height="23" colspan="4" align="center" bgcolor="#00CC66"><font color="#000000">上传文件前请输入您的用户信息,谢谢合作!</font></td>
</tr>
<tr>
<td width="33%" height="28" align="right" bgcolor="#FFFFFF"><font color="#000000" >用户:</font></td>
<td width="67%" align="left" bgcolor="#FFFFFF"><input name="id" size="15" maxlength="15" tpye="text"></td>
</tr>
<tr>
<td height="24" align="right" bgcolor="#FFFFFF"><font color="#000000" >密码:</font></td>
<td align="left"><input name="password" type="password" size="15" maxlength="15" >
<input type="hidden" name="max_file_size" value="10000000"></td>
</tr>
<tr align="center" valign="top">
<td align="right" > 请选择文件: </td>
<td height="26" align="right" > </td>
</tr>
<tr align="center" valign="top" bgcolor="#FFFFFF">
<td align="right" > </td>
<td height="34" align="left" valign="middle"><input name="userfile" type="file"></td>
</tr>
<tr align="center" valign="top" bgcolor="#FFFFFF">
<td align="right" > </td>
<td height="27" align="left" ><input name="submit" type="submit" value="上传文件">
</td>
</tr>
</form>
</table>';
break;
case "copy":
$connect_id=mysql_connect("$db_host","$db_user","$db_pass");
echo $connect_id;
mysql_select_db($db_database, $connect_id);
$query_string="select count(*) as number from $db_table_user where id=\"$id\" and password=\"$password\"; ";
//echo $query_string;
$result=mysql_query($query_string,$connect_id);
$data=mysql_fetch_array($result);
$record_num=$data["number"];
echo $record_num;
if($record_num==0)
{
echo "用户名密码错误!只有注册用户才能上传文件!";echo '<br>';echo '<br>';echo '<br>';echo '<br>';
echo '如果您还没有注册,可以到<a href="regist.php" target="_self"><font color="green">这里注册!</font></a>';echo '<br>';
}
//echo $password;
else
{echo "用户:".$id;
$upload_filename=$homedir_upload.$userfile_name;
if(file_exists($upload_filename))
{
echo "文件已经存在";
exit;
}
if(copy($userfile, $upload_filename))
{
echo ",文件上传成功";
echo '<table width="80%" border="1">';
echo ' <tr bgcolor="#FFFFFF">
<td height="23" colspan="4" align="center" bgcolor="#00CC66"><font color="#000000">以下是您上传的文件信息,谢谢您上传文件!</font></td>
</tr>';
echo ' <tr>
<td width="33%" height="27" align="right" bgcolor="#FFFFFF"><font color="#000000" >文件名称:</font></td>
<td width="67%" align="left" bgcolor="#FFFFFF">';echo $userfile_name;echo '</td></tr>';
echo '<tr align="center" valign="top">
<td align="right" > 文件大小: </td>
<td height="12" align="left" >';
echo $userfile_size;
echo' Bytes</td></tr>';
echo '<tr><td height="23" align="right" bgcolor="#FFFFFF"><font color="#000000" >文件类型:</font></td>
<td align="left">'; echo $userfile_type;
echo ' </td> </tr>';
echo '<tr align="center" valign="top" bgcolor="#FFFFFF">
<td height="27" colspan="2" ><input type="submit" name="Submit" value="返回">
</td>
</tr>
</form>
</table>';
}
else
{
echo '上传文件失败!';
}
}
break;
default:break;
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top" nowrap><table width="100%" border="0">
<tr>
<td height="21" align="center" bgcolor="#FFFFFF"><hr width="85%" noshade color="#00CC66"></td>
</tr>
<tr>
<td height="12" align="center">Copyright @ HomeLee. All rights reserved.
</td>
</tr>
<tr>
<td height="12" align="center" bgcolor="#FFFFFF"> </td>
</tr>
</table></td>
</tr>
</table>
</center></body>
</html>