扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
<%@ Page Language="VB" Debug="true" %> <%@ import namespace="System.Data" %> <%@ import namespace="System.Data.oledb" %> <html> <script language="vbscript" runat="server"> sub uploadfile(sender as object, e as eventargs) if fileup.postedfile.contentlength<20 then errors.text="这么小的文件也要上传,背背就可以了." fileinfo.visible=false exit sub else errors.text="检验正常" fileinfo.visible=true end if *** 以上检查上传文件大小 respace.text="0" nowspace.text="0" *** respace指剩余空间,nowspace指已用空间 dim xh1 as string =user1.value dim kl1 as string =pass1.value *** xh1指帐号,kl1指口令 dim objconnstr as string="provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("ftpspace.mdb") *** 以上两行在源码中应为同一语句 dim objconn as oledbconnection = new oledbconnection(objconnstr) dim sql1 as string="select * from userlist where xh='"+xh1+"' and kl='"+kl1+"'" dim objrscc as oledbcommand= new oledbcommand(sql1,objconn) objconn.open() dim objrs as oledbdatareader = objrscc.executereader() dim ix as integer=0 dim maxs as long dim nows as long while ix=0 if objrs.read() then if objrs.item("xh")=xh1 then if objrs.item("kl")=kl1 then if objrs.item("checkx")=1 then ix=ix+1 maxs=objrs.item("maxspace") nows=objrs.item("nowspace") end if end if end if else ix=-1 end if end while *** 以上判定帐号与口令是否合法 if ix<=0 then errors.text="帐号口令错!或用户尚未通过认证,请等待管理员认证!" else if fileup.postedfile.contentlength>maxs-nows then if fileup.postedfile.contentlength>=maxs then errors.text="文件长度大于赋予空间大小,不能上传!" else errors.text="可用空间不足,请删除旧文件!" end if *** 以上判定用户空间的可用性 else dim obj4str as string="provider=microsoft.jet.oledb.4.0; data source=" & server.mappath("filelist.mdb") *** 以上两行在源码中为同一语句 dim obj4 as oledbconnection = new oledbconnection(obj4str) dim sql10 as string="select * from files" dim objrc1 as oledbcommand= new oledbcommand(sql10,obj4) obj4.open() dim objrsx as oledbdatareader = objrc1.executereader() dim fn11 as long =0 while objrsx.read() fn11=objrsx("filename") end while dim fn1 as string fn1=cstr(fn11+1) *** 以上为用户上传文件起一个唯一的主文件名 dim objc1str as string="provider=microsoft.jet.oledb.4.0; data source=" & server.mappath("filelist.mdb") *** 以上两行在源码中为同一语句 dim objc1 as oledbconnection = new oledbconnection(objc1str) dim sql3 as string="insert into files(filename,fsize, xh,filescript,upday) values("+cstr(fn1)+","+cstr(fileup.postedfile.contentlength)+",'" +xh1+"','"+fileup.postedfile.filename+"','"+cstr(now())+"')" *** 以上三行在源码中为同一语句 objc1.open() dim objrs1 as oledbcommand=new oledbcommand(sql3,objc1) dim fn2 as string fn2="d:/netspace/spacenet/myspace/"&cstr(fn1)&".zip" *** 给出用户上传文件的绝对路径及完整文件名 fsize.text=cstr(fileup.postedfile.contentlength) ftype.text=fileup.postedfile.contenttype fname.text=fileup.postedfile.filename username.text=user1.value fileup.postedfile.saveas(fn2) objrs1.ExecuteNonQuery() objrs.close dim sql5 as string="update userlist set nowspace ="+cstr(nows+fileup.postedfile.contentlength)+ ",lastaccessday='"+cstr(now())+"' where xh='"+xh1+"'" *** 以上两行在源码中为同一语句 dim objrnc as oledbcommand= new oledbcommand(sql5,objconn) objrnc.executenonquery() respace.text=cstr(maxs-nows-fileup.postedfile.contentlength)&"字节." nowspace.text=cstr(nows+fileup.postedfile.contentlength)&"字节." *** 以上作上传动作,并计算用户的已用总空间及剩余总空间 end if end if end sub </script> <body> <form enctype="multipart/form-data" runat="server"> <table> <tr><td>帐号:</td><td><input id="user1" runat="server"></td></tr> <tr><td>口令:</td><td><input type="password" id="pass1" runat="server"></td></tr> <tr><td>文件:</td><td><input type="file" id="fileup" runat="server"></td></tr> <tr><td></td><td><asp:button id="upload" onclick="uploadfile" text="上传" runat="server"/></td></tr> </table> </form><hr> <div id="fileinfo" visible="false" runat="server"> 原文件名:<asp:label id="fname" runat="server"/><br> 字节大小:<asp:label id="fsize" runat="server"/><br> 文件类型:<asp:label id="ftype" runat="server"/><br> 用户帐号:<asp:label id="username" runat="server"/><br> 剩余空间:<asp:label id="respace" runat="server"/><br> 已用空间:<asp:label id="nowspace" runat="server"/><br> 上传状态:<asp:label id="errors" runat="server"/> </div> *** 以上在浏览器中告诉用户文件上传前后的相关信息 </body> </html> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者