www.gusucode.com > ASP+ACCESS在线教育系统设计(源代码+论文) > ASP+ACCESS在线教育系统设计(源代码+论文)\王智_在线教育系统\uploadaction.asp

    <%@ Language=VBScript %>
<% Response.Expires=0 %>
<!-- #Include file="include\adovbs.inc" -->
<%
sub msgerror
	Response.Write "<script language=vbscript runat=server>"&chr(10)&chr(13)
	Response.Write "sub window_onload"&chr(10)&chr(13)
	Response.Write "	msgbox ""错误的用户名或密码!"",0,""清华网络学堂"""&chr(10)&chr(13)
	Response.Write "	window.history.back"&chr(10)&chr(13)
	Response.Write "end sub"&chr(10)&chr(13)
	Response.Write "</script>"&chr(10)&chr(13)
end sub

sub msgfail
	Response.Write "<script language=vbscript runat=server>"&chr(10)&chr(13)
	Response.Write "sub window_onload"&chr(10)&chr(13)
	Response.Write "	msgbox ""您已经提交过该次作业并且已批改过,此次提交无效!"",0,""清华网络学堂"""&chr(10)&chr(13)
	Response.Write "	window.history.back"&chr(10)&chr(13)
	Response.Write "end sub"&chr(10)&chr(13)
	Response.Write "</script>"&chr(10)&chr(13)
end sub

sub msgsuccess
	Response.Write "<script language=vbscript runat=server>"&chr(10)&chr(13)
	Response.Write "sub window_onload"&chr(10)&chr(13)
	Response.Write "	msgbox ""作业提交成功!"",0,""清华网络学堂"""&chr(10)&chr(13)
	Response.Write "	window.location.href=""uploadform.asp"""&chr(10)&chr(13)	
	Response.Write "end sub"&chr(10)&chr(13)
	Response.Write "</script>"&chr(10)&chr(13)
end sub
%>

<%
	Set Post = Server.CreateObject("ActiveFile.Post")
	Post.Upload server.MapPath("./tempforupload")

	' not into the database, just for creating the fileobject
	filepath = Post.FormInputs("zipfile").file.name

	num = Post.FormInputs("num").value
	passwd = Post.FormInputs("passwd").value
	id_num = Post.FormInputs("id_num").value
	set Post = nothing


'   验证密码
	set conn = server.CreateObject("adodb.connection")
	conn.Open Application("dsn")

	strSQL = "select passwd from student where num = '" & num & "'"
	set rs = server.CreateObject("adodb.recordset")
	rs.Open strSQL,conn
	if rs.EOF then
		set filesystem = createobject("scripting.FileSystemObject")		
		filesystem.DeleteFile filepath,1
		set filesystem = nothing
		rs.Close
		set rs = nothing
		conn.close
		set conn = nothing
		msgerror
		Response.End
	end if
	if rs("passwd") <> passwd then
		set filesystem = createobject("scripting.FileSystemObject")		
		filesystem.DeleteFile filepath,1
		set filesystem = nothing
		rs.Close
		set rs = nothing
		conn.close
		set conn = nothing
		msgerror
		Response.End
	end if
	rs.Close
	set rs = nothing
	conn.Close
	set conn = nothing


	set filesystem = createobject("scripting.FileSystemObject")		

	if filesystem.FileExists(server.MapPath("./homework") & "\" & num & id_num & "x.zip") then
		msgfail
		Response.End
	end if

	if filesystem.FileExists(server.MapPath("./homework") & "\" & num & id_num & ".zip") then
		filesystem.deleteFile server.MapPath("./homework") & "\" & num & id_num & ".zip"
	end if
	
	filesystem.CopyFile filepath,server.MapPath("./homework") & "\" & num & id_num & ".zip",1
	filesystem.DeleteFile filepath,1
	set filesystem = nothing
	
	msgsuccess
%>