<!--#include file="IsLogin.asp" --><html>
<head>
<title>上传3</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
body {
	margin-left: 0px;
	margin-top: 0px;
}
-->
</style></head>
<body>
<%mUserID=request("mUserID")%>
<table width="100%" height="24" border="0">
<tr>
<td height="20" align="left" class="baizi">
<% server.scripttimeout=900 %>
<%
FilePath="../Photo/SmallImages/"&mUserID&"/"
FileMaxSize=8020
FileType=".jpg.gif"
fileweb=""
nameset =1
pathset =0
%>
<% 
''将当前的日期和时间转为文件名
function makefilename(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,"下午","")
  makefilename=fname
end function 
%>
<!--#include file="upload_img.inc"-->
<%
dim upload,file,formName,iCount
dim url,url1
set upload=new upload_img ''建立上传对象

if Pathset > 0 then   ''得到上传目录
 UpFilePath = upload.form("filepath")
else
 UpFilePath = FilePath
 ''在目录后加(/)
 if right(UpFilePath,1)<>"/" then UpFilePath=UpFilePath&"/" 
end if
iCount=0
for each formName in upload.file ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象
 if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
 if file.FileSize<FileMaxSize then ''如果未超过文件大小限制

 if FileType<>"" then	'如果限制了上传文件类型
 if Instr(FileType,GetExtendName(file.FileName)) then
	TypeFlag = 1        '文件为允许的类型
 else
	TypeFlag = 0		'文件为不允许的类型
 	Response.write "不支持您所上传的文件类型："
	Response.write GetExtendName(file.FileName)
end if
 else
 TypeFlag = 1			'没有限制上传文件类型
 
 end if

  if TypeFlag = 1 then 
  vfname = makefilename(now())
     if nameset = 1 then
  fname = vfname & iCount & "." & GetExtendName(file.FileName)
       elseif nameset =2 then
	   fname = file.FileName
	     elseif nameset = 3 then
		 fname = vfname & iCount & file.FileName
		 end if
  file.SaveAs Server.mappath(UpFilePath&fname)   ''保存文件
  Smallfilename = FilePath&fname

  iCount=iCount+1
  if request.cookies("usr")="" then

 Response.Write "<script language="&chr(34)&"javascript"&chr(34)&">"&chr(13)&chr(10)
 Response.Write "cdir();"&chr(13)&chr(10)
 Response.Write "function cdir() {"&chr(13)&chr(10)
 
 Response.Write "if (parent.document.form1.t2.value != '' || parent.document.form1.t2.value.indexOf('|') != -1){"
 
 Response.Write "parent.document.form1.t2.value=parent.document.form1.t2.value+"&chr(34)&""&fname&chr(34)&";"&chr(13)&chr(10)
 Response.Write "parent.form1.hidImageSize.value='"&file.FileSize&"';parent.document.images['imgShow'].src='"&Smallfilename&"';"
 Response.Write "}else{"
 
 Response.Write "parent.document.form1.t2.value="&chr(34)&""&fname&chr(34)&";"&chr(13)&chr(10)
  Response.Write "parent.form1.hidImageSize.value='"&file.FileSize&"';parent.document.images['imgShow'].src='"&Smallfilename&"';"

  Response.Write "}"
 
 Response.Write "}"&chr(13)&chr(10)
 Response.Write "</script>"&chr(13)&chr(10)
 
  else
 
 Response.Write "<script language="&chr(34)&"javascript"&chr(34)&">"&chr(13)&chr(10)
 Response.Write "cdir();"&chr(13)&chr(10)
 Response.Write "function cdir() {"&chr(13)&chr(10)
 Response.Write "if (parent.document.form1.t2.value != '' || parent.document.form1.t2.value.indexOf('|') != -1){"
 Response.Write "parent.document.form1.t2.value=parent.document.form1.t2.value+'|'+"&chr(34)&""&fname&chr(34)&";"&chr(13)&chr(10)
 Response.Write "}else{"
 Response.Write "parent.document.form1.t2.value="&chr(34)&""&fname&chr(34)&";"&chr(13)&chr(10)
 Response.Write "}"
 Response.Write "}"&chr(13)&chr(10)
 Response.Write"kkk();"&chr(13)&chr(10)
 Response.Write" function kkk() {"&chr(13)&chr(10)
 Response.Write "parent.document.form1.image1.src="&chr(34)&fname&chr(34)&";"&chr(13)&chr(10)
 Response.Write "}"&chr(13)&chr(10)
 Response.Write "</script>"&chr(13)&chr(10)
 end if
 end if
 if TypeFlag <> 0 then
Response.Write "上传成功"
session("number")=1
 end if
 else
 response.write "文件大小超出限制，您最多可以上传 "& FileMaxSize &"个字节的文件数据"
 exit for
 end if
 end if
 set file=nothing
next
set upload=nothing  ''删除此对象

if iCount=0 then
  response.write "<br>上传文件失败，请向管理员反应!"
  response.write ""&Msg&" [<a href=""javascript:history.back();"">从这里返回</a>]"
  response.end
end if

sub HtmEnd(Msg)
 set upload=nothing
end sub


function GetExtendName(FileName)
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,3)
ExtName = right(ExtName,3-Instr(ExtName,"."))
GetExtendName = ExtName
end function
        %>
</td>
</tr>
</table>
</body>
</html>