<html>
<head>
<title>添加文件</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="js/common.css" rel="stylesheet" type="text/css">
</head>
<body>
<form method="post" action="uploadfile.asp?todo=uploadfile" enctype="multipart/form-data">
  <table border=0 cellspacing=0 cellpadding=0 align=left width="500">
    <tr> 
      <td height=20 width=60>　　文件</TD>
<td height="16" width="371"> 
<input type="file" name="src" size="20" value="浏览">
&nbsp;&nbsp; 
<input type="submit" value="文件上传" name="B1" IsShowProcessBar="True">
      </td>
</tr>
</table>
</form>
<%
If Request("todo")="uploadfile" Then
%>
<p><br>
  <!--#include FILE="Inc/upload.inc"-->
  <%dim upload,file,formName,formPath,iCount
set upload=new upload_F
	function MakedownName()
		dim fname
	  	fname = now()
		fname = replace(fname,"-","")
	 	fname = replace(fname," ","") 
		fname = replace(fname,":","")
	  	fname = replace(fname,"PM","")
	  	fname = replace(fname,"AM","")
		fname = replace(fname,"上午","")
	  	fname = replace(fname,"下午","")
	  	fname = int(fname) + int((10-1+1)*Rnd + 1)
		MakedownName=fname
	end function 
formPath="Pic/"
iCount=0
for each formName in upload.file ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象
 if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
newname=MakedownName()&"."&mid(file.FileName,InStrRev(file.FileName, ".")+1)
  file.SaveAs Server.mappath(formPath&newname)   ''保存文件
  iCount=iCount+1
Else 
  response.write "未找到文件 &nbsp;&nbsp;<A HREF=javascript:history.back(1)>返回</A>"
  response.end
 end if
next
%>
<br>
  <%
Response.write "　　文件大小：" & Cint(file.FileSize/1024) & "K<br>"
Response.write "　　相对地址：" & "Admin/Pic/" & newname & "<br>"
Response.write "　　IP地址：" & ServerPath & "pic/" & newname 
End If
set file=nothing
set upload=nothing  ''删除此对象
%>
  <%
Public Function ServerPath 
Dim Path
Dim Pos
Path="http://" & Request.ServerVariables("server_name") & Request.ServerVariables("script_name")
Pos=InStrRev(Path,"/")
ServerPath=Left(Path,Pos)
End Function
%>
</p>
</body>
</html>