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

📄 upload.asp

📁 一个不错的企业网站源代码!
💻 ASP
字号:
<%@ Language=VBScript %>
<%
Response.Buffer=false
Response.Expires=0
%>
<!-- #include file="../dsn.asp" -->
<%
tabname=Request.QueryString ("tablename")
ids=cint(Request.QueryString ("id"))
pic=Request.QueryString ("pic")
picsize=Request.QueryString ("picsize")
delid=Request.QueryString ("delid")
if pic="" then
		pic=0
end if
if tabname="bbsuser" then 
		filer="userid"
	else
		filer="id"
end if
set cn=server.CreateObject("ADODB.Connection")
cn.Open mycnstr
set rs=server.createobject("ADODB.recordset") 
sqltext="select * from "+tabname+" where "+filer+"="&ids
rs.Open sqltext,cn,1,1
if not rs.EOF then
		if pic=0 then
				picif=rs("picflag")
		elseif pic=1 then
				picif=rs("picflag1")
		elseif pic=2 then
				picif=rs("picflag2")
		elseif pic=3 then
				picif=rs("picflag3")
		end if
end if
rs.Close 
%>

<%
if picsize<>0 then
		htmlname="upload.asp?id="&ids&"&pic="&pic&"&delid="&ids&"&picsize="&picsize&"&tablename="+tabname+""
	else
		htmlname="upload.asp?id="&ids&"&pic="&pic&"&delid="&ids&"&tablename="+tabname+""
end if
if delid<>0 then
		rs.Open sqltext,cn,1,3
		if not rs.EOF then
				if pic=0 then
						rs("picfile")=""
						rs("picflag")=0
				elseif pic=1 then
						rs("picfile1")=""
						rs("picflag1")=0
				elseif pic=2 then
						rs("picfile2")=""
						rs("picflag2")=0
				elseif pic=3 then
						rs("picfile3")=""
						rs("picflag3")=0			
				end if
				rs.Update 
				delid=0
		end if
		rs.Close 
end if

%>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {font-size: 12px; color: #000000; font-family: 宋体}
td {font-size: 12px; color: #000000; font-family: 宋体;line-height:130%}
.t1 {font:12px 宋体;color=000000} 
.t2 {font:12px 宋体;color:ffffff} 
-->
</style>
</head>
<title>图片维护</title>
<body bgcolor="#FF6633" leftmargin="1" topmargin="0" marginwidth="0" marginheight="0">
<form name="form2" enctype="multipart/form-data" action="<%=htmlname%>" method="post" onsubmit="return checkform()"> 
<%
if picif=0 then
		if Request.ServerVariables("REQUEST_METHOD") = "POST" then
				formsize=request.totalbytes 
				bz="1"
				if picsize<>0 then
						if clng(picsize)<formsize then
							bz="0"	
							sysmess="上传图片文件太大!文件限为("&picsize&")目前为("&formsize&")"	
						end if
				end if
				if bz=1 then
						formdata=Request.BinaryRead(formsize)
						bncrlf=chrB(13)&chrB(10)
						divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
						datastart=instrb(formdata,bncrlf & bncrlf)+4 
						dataend=instrb(datastart+1,formdata,divider)-datastart
						mydata=midb(formdata,datastart,dataend) 
						sqltext="select * from "+tabname+" where "+filer+"="&ids
						rs.Open sqltext,cn,1,3
						if pic=0 then
								rs("picfile").AppendChunk mydata
								rs("picflag")=1
						elseif pic=1 then
								rs("picfile1").AppendChunk mydata
								rs("picflag1")=1
						elseif pic=2 then	
								rs("picfile2").AppendChunk mydata
								rs("picflag2")=1
						elseif pic=3 then	
								rs("picfile3").AppendChunk mydata
								rs("picflag3")=1
						end if
						rs.Update
						rs.Close
						Response.Write("<script language=Javascript>")
						if tabname="bbsuser" then
								Response.Write("window.opener.top.location.reload();")
							else
								Response.Write("window.opener.top.main.location.reload();")
						end if
						Response.Write("window.close();")
						Response.Write("</script>")
				end if 
		end if
end if
		'Response.Write sqltext
		rs.Open sqltext,cn,1,3
%>
      <table width="100%" border="0" height="100%" bgcolor="#FF6633" cellpadding="2" cellspacing="1">
        <tr bgcolor="#FF6633"> 
          <td height="10">&nbsp;</td>
        </tr>
        <tr bgcolor="#FFFFFF" align="center"> 
          <td height="280">
          	<%
			if sysmess<>"" then
				Response.Write("<font color=red>提示:"+sysmess+"</font><br>")
			end if
      if pic=0 then    
                 if rs("picflag")=1 then%>
						<img src="jpg.asp?id=<%=ids%>&tabname=<%=tabname%>&pic=<%=pic%>" border="0">
					<%else%>
          				现没有图片
				<%end if
	  elseif pic="1" then
                 if rs("picflag1")=1 then%>
						<img src="jpg.asp?id=<%=ids%>&tabname=<%=tabname%>&pic=<%=pic%>" border="0">
					<%else%>
          				现没有图片
				<%end if		
	  elseif pic="2" then
                 if rs("picflag2")=1 then%>
						<img src="jpg.asp?id=<%=ids%>&tabname=<%=tabname%>&pic=<%=pic%>" border="0">
					<%else%>
          				现没有图片
          		<%end if
	  elseif pic="3" then
                 if rs("picflag3")=1 then%>
						<img src="jpg.asp?id=<%=ids%>&tabname=<%=tabname%>&pic=<%=pic%>" border="0">
					<%else%>
          				现没有图片
				<%end if
	  end if
		%>
		</td>
        </tr>
        <tr bgcolor="#FFFFFF"> 
          <td> 
            <table width="100%" border="0">
              <tr align="center"> 
                <td>
                    上传图片文件&nbsp;<input type="file" name="filename">
                </td>
              </tr>
              <tr align="center"> 
                <td height="5"></td>
              </tr>
              <tr align="center"> 
                 <td>
      <%
      if pic=0 then    
                 if rs("picflag")=1 then%>
							<input type="button" name="delete" value="删除图片" onclick="Javascript:delpic()">
						<%else%>						
							 <input type="submit" name="Submit" value="上传图片">&nbsp;&nbsp;&nbsp;&nbsp;
				<%end if
		elseif pic="1" then
                 if rs("picflag1")="1" then%>
							<input type="button" name="delete" value="删除图片" onclick="Javascript:delpic()">
						<%else%>						
							 <input type="submit" name="Submit" value="上传图片">&nbsp;&nbsp;&nbsp;&nbsp;
				<%end if		
		elseif pic="2" then
                 if rs("picflag2")="1" then%>
							<input type="button" name="delete" value="删除图片" onclick="Javascript:delpic()">
						<%else%>						
							 <input type="submit" name="Submit" value="上传图片">&nbsp;&nbsp;&nbsp;&nbsp;
				<%end if
		elseif pic="3" then
                 if rs("picflag3")="1" then%>
							<input type="button" name="delete" value="删除图片" onclick="Javascript:delpic()">
						<%else%>						
							 <input type="submit" name="Submit" value="上传图片">&nbsp;&nbsp;&nbsp;&nbsp;
				<%end if
		end if
		%>
                   
                    <input type="button" name="cancel" value="关闭" onclick="Javascript:window.opener.top.main.location.reload();window.close()"></form>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
</form>
</body>
</html>
<script language=Javascript>
	function checkform(form1)
	{
		var filename
		filename=document.form2.filename.value
		if (filename=="") 
			{ return false}
		return true
	}
	
	function delpic()
	{
		if (confirm('您确认要删除该图片吗?')==true)
		{
		window.location.href="<%=htmlname%>"
		return false;
		}
	}
</script>

⌨️ 快捷键说明

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