📄 upload.asp
字号:
<!--#include file="Conn.asp"-->
<!--#include file=inc.asp-->
<!--#include file="UpLoadClass.asp"-->
<%If Session("UserName")="" OR Session("UserId")="" Then
Response.Write("<script language=JavaScript>alert('您还没有登陆!');document.location.href='index.asp';</script>")
Response.End
End if
%>
<%Server.ScriptTimeOut=99999999%>
<%
Dim action
action = trim(request.QueryString("action"))
SELECT Case action
Case "SaveNew"
Call SaveNew()
Case else
Call add()
End SELECT
'============================
Sub SaveNew()
If ChkPost=false Then
Response.Write("<script language=JavaScript>alert('请不要重外部提交信息!');document.location.href='index.asp';</script>")
Response.End
End If
if Session("UserMaxUp")="" or Session("UserMaxUp")<=0 then
Response.Write("<script language=JavaScript>alert('您不允许上传文件,需要上传请与管理员联系!');document.location.href='index.asp';</script>")
Response.End
End If
dim rs,sql
dim FileTitle,FileAbout
'===============================================
dim upload,FileUrl,filesize
set upload=New UpLoadClass ''建立上传对象
'以默认设置打开上传对象
'建议直接修改类的63,64,65,66行为自己需要的默认设置
'类的初始默认值分别为
'p_MaxSize = 153600 单文件最大150K
'p_FileType = "jpg/gif" 允许上传jpg/gif格式文件
'p_SavePath = "" 在当前目录保存文件,这里是相对路径,如:“UpLoadFile/”
'p_AutoSave = 0 自动生成无重复文件名保存目标文件
'这样每次就不要设置同样的参数了
upload.open()
FileTitle=replace(trim(upload.form("FileTitle")),"'","")
FileAbout=replace(rtrim(upload.form("FileAbout")),"'","")
if FileTitle = "" then
set upload=nothing
Response.Write("<script language=JavaScript>alert('课件名称不能为空!');document.location.href='javascript:window.history.go(-1);';</script>")
exit sub
end if
if upload.Error=3 Then
set upload=nothing
Response.Write("<script language=JavaScript>alert('上传失败,文件太小或没有选择文件!');document.location.href='javascript:window.history.go(-1);';</script>")
exit sub
end if
if upload.Error=1 Then
set upload=nothing
Response.Write("<script language=JavaScript>alert('上传失败,文件超过您能上传的大小!');document.location.href='javascript:window.history.go(-1);';</script>")
exit sub
end if
if upload.Error=2 Then
set upload=nothing
Response.Write("<script language=JavaScript>alert('上传失败,不允许上传此类型文件!');document.location.href='javascript:window.history.go(-1);';</script>")
exit sub
end if
FileUrl=upload.Form("FileUrl")
filesize=upload.filesize
if upload.Error<>0 OR FileUrl="" or FileTitle="" or filesize="" or filesize=<0 then
set upload=nothing
Response.Write("<script language=JavaScript>alert('文件上传失败!请确认已经正确选择上传文件!');document.location.href='javascript:window.history.go(-1);';</script>")
exit sub
end if
set upload=nothing ''删除此对象
set rs=server.CreateObject("adodb.recordset")
sql="select * from [Files]"
If Not IsObject(Conn) Then ConnectionDatabase()
rs.open sql,conn,1,3
rs.addnew
rs("UserId")=Session("UserId")
rs("UserName")=Session("UserName")
rs("FileTitle")=FileTitle
rs("FileAbout")=FileAbout
rs("FileUrl")=FileUrl
rs("filesize")=filesize
rs.update
rs.close
set rs=nothing
Conn.Execute("Update Users set UpFiles=UpFiles+1 Where UserId='"&Session("UserId"))&"'"
CloseDatabase()
Response.Write("<script language=JavaScript>alert('课件上传成功!文件大小:"&myfilesize(filesize)&" ');document.location.href='index.asp';</script>")
End Sub
'============================
Sub add()
dim rs
dim styeid
Call Top("上传课件","UpLoad.asp")
%>
<TABLE style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid"
cellSpacing=0 cellPadding=0 width=778 align=center bgColor=#f7f7f7 border=0>
<TBODY>
<TR>
<TD vAlign=top width=220>
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
<TBODY>
<TR>
<TD
background=images/side_bg_r1_c1.gif
height=34>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width=10></TD>
<TD width=20><IMG height=14
src="images/ico_015.gif"
width=13 border=0></TD>
<TD width=100>用户登陆</TD>
<TD width=85></TD>
<TD width=5></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD
background=images/side_bg_r2_c1.gif>
<TABLE cellSpacing=0 cellPadding=0 width=200 align=center
border=0><TBODY>
<TR>
<TD align="center">
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="34%" align="right">欢 迎 您:</td>
<td width="66%"><%=Session("UserName")%></td>
</tr>
<tr>
<td align="right">登陆次数:</td>
<td><b><%=Session("UserLogins")%></b></td>
</tr>
<tr>
<td align="right">上传课件:</td>
<td><font color=red>
<%If Not IsObject(Conn) Then ConnectionDatabase()%>
<%=Conn.execute("Select UpFiles from Users Where UserId='"&Session("UserId")&"'")(0)%>
</font>个</td>
</tr>
<tr>
<td align="right">相关操作:</td>
<td><a href="UpLoad.asp"><font color=red>上传课件</font></a>
<a href="Edit.asp?Id=<%=Session("UserId")%>">修改资料</a>
<%If Session("UserAdmin") Then Response.Write"<a href=Admin.asp>添加用户</a>"%>
</td>
</tr>
<tr>
<td height="3" colspan="2"></td>
</tr>
<tr>
<td></td>
<td align="right"><input name="Logout" type="button" id="Logout" value="退出" onClick="location.href='Login.asp?action=logout'"> </td>
</tr>
</table>
</TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD
background=images/side_bg_r3_c1.gif
height=4></TD></TR></TBODY></TABLE> </TD>
<TD width=1 bgColor=#b4b4b4></TD>
<TD width=1 bgColor=#ffffff></TD>
<TD width=1></TD>
<TD vAlign=top width=553><table cellspacing=0 cellpadding=0 width=553 align=center border=0>
<tbody>
<tr>
<td width=2 rowspan=2></td>
<td width=548><table cellspacing=0 cellpadding=0 width=548 border=0>
<tbody>
<tr>
<td width=120
background=images/ad_title.gif
height=30><table cellspacing=0 cellpadding=0 width=120 border=0>
<tbody>
<tr>
<td colspan=2 height=6></td>
</tr>
<tr>
<td width=10></td>
<td nowrap>▍上传课件</td>
</tr>
<tr>
<td colspan=2 height=0></td>
</tr>
</tbody>
</table></td>
<td align=middle width=428
background=images/ad_title_bg.gif
height=30></td>
</tr>
</tbody>
</table></td>
<td width=3 rowspan=2></td>
</tr>
<tr>
<td width=548><table cellspacing=0 cellpadding=0 width=548 border=0>
<tbody>
<tr>
<td><table cellspacing=0 cellpadding=0 width=548 border=0>
<tbody>
<tr>
<td width=1 bgcolor=#d4d4d4></td>
<td width=1 bgcolor=#ffffff></td>
<td align=middle width=544 height=100><form name="form" method="post" action="?action=SaveNew" enctype="multipart/form-data" onSubmit="javascript:Submit.disabled=true;Submit.value='请稍后...';">
<table border="0" align="center" cellpadding="2" cellspacing="1">
<tr>
<td width="88" align="right">课件名称:</td>
<td width="445"><input name="FileTitle" type="text" id="FileTitle" size="25" maxlength="60"></td>
</tr>
<tr>
<td align="right">课件路径:</td>
<td>
<input name="FileUrl" type="file" id="FileUrl" size="25">
<%if Session("UserMaxUp")="" or Session("UserMaxUp")<=0 Then
response.write "<br>您不允许上传文件,需要上传请与管理员联系。"
else
%>
<BR>
您只能上传<font color="#FF0000"><%=Session("UserMaxUp")%><strong>KB</strong></font>内的<strong>RAR</strong>和<strong>ZIP</strong>文件
<%end if%>
</td>
</tr>
<tr>
<td align="right">课件说明:</td>
<td><label>
<textarea name="FileAbout" cols="60" rows="6" id="FileAbout"></textarea>
</label></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="Submit" value="上传">
<input type="reset" name="Submit2" value="重置"></td>
</tr>
</table>
</form></td>
<td width=1 bgcolor=#ffffff></td>
<td width=1 bgcolor=#d4d4d4></td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td><table cellspacing=0 cellpadding=0 width=548 border=0>
<tbody>
<tr>
<td width=1 bgcolor=#d4d4d4></td>
<td bgcolor=#ffffff height=1></td>
<td width=1 bgcolor=#d4d4d4></td>
</tr>
<tr>
<td bgcolor=#d4d4d4 colspan=3
height=1></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table></TD>
</TR></TBODY></TABLE>
<TABLE
style="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #c0c0c0 1px solid; BORDER-BOTTOM-WIDTH: 1px; BORDER-LEFT: #c0c0c0 1px solid"
cellSpacing=0 cellPadding=0 width=778 align=center bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD bgColor=#dbe2e8 height=1></TD></TR>
<TR>
<TD bgColor=#ffffff height=1></TD></TR>
<TR>
<TD bgColor=#c5cfd9 height=1></TD></TR>
<TR>
<TD bgColor=#dbe2e8 height=1></TD></TR></TBODY></TABLE>
<%Call Bottom()%>
</body>
</html>
<%
End Sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -