⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addfile.aspx

📁 一个完整的办公自动化源码,免费提供给大家下载
💻 ASPX
字号:
<%@ Page Language="VB" ContentType="text/html" debug="true"  %>
<%@ Import Namespace="system.data" %>
<%@ Import Namespace="system.data.oledb" %>
<html>
<head>
<title>添加文件到收藏夹</title>
<link href="CSS.CSS" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body   bgcolor="#CCCCCC">
<asp:panel runat="server" ID="zpa1" >
<!--显示主窗口的层-->
<form runat="server" enctype="multipart/form-data">
<table width="549" height="22" border="0" cellpadding="0" cellspacing="0" background="pic/002.png">
  <tr> 
    
    <td width="201"><strong><font color="#FFFFFF">&nbsp;&nbsp;&nbsp;&nbsp;我的收藏夹</font></strong></td>
    <td width="10">&nbsp;</td>
    <td width="282">&nbsp;</td>
  </tr>
</table>
<table width="549" height="400" border="1" cellpadding="0" cellspacing="0" bordercolorlight="#008080" bordercolordark="#FFFFFF">
  <tr>
    <td height="155" valign="top" bgcolor="#FFFFFF"> 
        <div align="center"> 
          <center>
            <table border="0" width="98%" height="94" bgcolor="#FFFFFF" cellspacing="1">
              <tr bgcolor="#FFFFFF"> 
                <td width="103" height="25" align="center"> <font color="#000000"><img src="pic/images/Chat.gif" width="20" height="16" align="absbottom">文档描述:</font></td>
                
              <td width="192" height="25"> <font color="#000000"> 
                <asp:textbox BorderStyle="solid" BorderWidth="1" Columns="25" Font-Size="10" ID="ztitle" MaxLength="20" runat="server" TextMode="SingleLine" />
<asp:requiredfieldvalidator ControlToValidate="ztitle" Display="Dynamic" ErrorMessage="收藏文件标题不能为空!" ID="rztitle" runat="server" Text="*" /> <asp:validationsummary DisplayMode="List" HeaderText="您的输入有下列错误:" ID="rerror" runat="server" ShowMessageBox="true" ShowSummary="false" />               </font></td>
                <td width="207" rowspan="2"> <table width="207" align="center" cellpadding="0">
                    <tr> 
                      <td width="189"><font color="#000000"><br>
                        <img src="pic/images/Ico.gif" width="10" height="10">文档描述最多不超过20字!!<br>
                        <br>
                        <img src="pic/images/Ico.gif" width="10" height="10">上传文件最大不能超过5M!!<br>
                        <br>
                        <img src="pic/images/Ico.gif" width="10" height="10">禁止上传EXE等文件,请先压缩!!</font></td>
                    </tr>
                  </table></td>
              </tr>
              <tr bgcolor="#FFFFFF"> 
                <td width="103" height="29" align="center"><font color="#000000"><img src="pic/images/icon_folder_open_topic.gif" width="15" height="15" align="absbottom">文档地址:</font></td>
                <td width="192" height="29"> <font color="#000000"> 
                  <input id="myfile" type="file" style="border-width:1px;border-style:Solid;font-size:10pt;" size="20" runat="server">
                  </font></td>
              </tr>
            </table>
            <p>&nbsp;</p>
            
          <p> 
            <asp:button Font-Size="10" ID="zsave" runat="server" Text="加入收藏" OnClick="zscsave" />
            &nbsp; </p>
          </center>
        </div>
  </td>
  </tr>
</table>
</form>
<!--主窗口的层显示完毕-->
</asp:panel>

<asp:panel runat="server" ID="zpa2" Visible="false">
<!--文件传送失败的层-->
<br>
<br>
<br>
<p align="center"><font color="#FF0000"><br>
  <img src="pic/Image23.gif" width="32" height="32"> 文件传输失败!!!<br>
  <br>
  <br>
  </font></p>
</asp:panel>

<asp:panel runat="server" ID="zpa3" Visible="false">
<!--文件传送失败的层-->
<br>
<br>
<br>
<p align="center"><font color="#FF0000"><br>
  <img src="pic/Image13.gif" width="32" height="32"> 成功!!!<br>
  <br>
  <br>
  </font></p>
</asp:panel>


</body>
</html>
<script language="VB" runat="server">
	sub zscsave(s as object,e as eventargs)
		dim conn as new oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath("office.mdb"))
		conn.open()
		dim objcmd as new oledbcommand()
		objcmd.connection=conn
		if myfile.postedfile.contentlength=0 then
			zpa1.visible=false
			zpa2.visible=true
			exit sub
			'显示失败信息
		end if
			dim lsfile as object
			lsfile=myfile.postedfile
			dim lsname() as string=split(lsfile.filename,".")
			dim lsnm as string=lsname(lsname.length-1)
			dim lstime=now()
			dim lsyear,lsmonth,lsday,lshour,lsminute,lssecond,lsfilename as string
			lsyear=year(lstime)
			lsmonth=right("0" & month(lstime),2)
			lsday=right("0" & day(lstime),2)
			lshour=right("0" & hour(lstime),2)
			lsminute=right("0" & minute(lstime),2)
			lssecond=right("0" & second(lstime),2)
			dim lsrd as string
			randomize
			lsrd=cstr(int(100*rnd())+1)
			lsfilename=lsyear & lsmonth & lsday & lshour & lsminute & lssecond & "-" & lsrd  & "." & lsnm
			'得到以当前日期及时间为前缀的新文件名,只保留原文档的护展名(防止文件出现重名现象、防止中文文件名)
			dim lspath as string
			lspath=session("uppath") & lsfilename
			lsfile.saveas(lspath)
		'将文件保存到服务器odownload目录
		objcmd.commandtext="insert into myfile (myid,mytitle,sizeZ,myfilename) " & _
							" values(?,?,?,?)"
		dim oinfo()=session("lguinfo")
		objcmd.parameters.add("@myid",oledbtype.char).value=oinfo(0)							
		objcmd.parameters.add("@mytitle",oledbtype.char).value=ztitle.text
		if myfile.postedfile.contentlength>1024 then
			objcmd.parameters.add("@sizeZ",oledbtype.char).value=int(myfile.postedfile.contentlength/1024) & "Kb"
		else
			objcmd.parameters.add("@sizeZ",oledbtype.char).value=myfile.postedfile.contentlength & "Byte"
		end if
		objcmd.parameters.add("@myfilename",oledbtype.char).value=lsfilename
		objcmd.executenonquery()
		conn.close()
		zpa1.visible=false
		zpa3.visible=true
	end sub
</script>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -