<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
function GetFileName(ByVal strFile)
if strFile <> " " then
GetFileName = mid(strFile,InstrRev(strFile,"\")+1)
else
GetFileName = " "
end if
end function
strFileName =Request.Form("upload")
set objStream = Server.CreateObject("ADODB.Stream")
objStream.type = 1 
objStream.open 
objStream.LoadFromFile strFileName
'objStream.saveToFile server.MapPath("/upload/"&GetFileName(strFileName)),2
fileExt=trim(right(strFileName,3))strJS="<SCRIPT language=javascript>" & vbcrlf
if FoundErr<>true then
randomize
ranNum=int(900*rnd)+100
filename=SavePath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
objStream.SaveToFile server.MapPath("/upload/"&GetFileName(filename)),2   '保存文件

strJS=strJS & "parent.document.form.s_img.value='" & fileName & "';" & vbcrlf
else
strJS=strJS & "alert('" & msg & "');" & vbcrlf
   strJS=strJS & "history.go(-1);" & vbcrlf
end if
strJS=strJS & "</script>" & vbcrlf
response.write strJSresponse.Write("<script>alert('上传成功');location.href='upload.asp';</script>")
objStream.close
%>