asp利用檔案上傳組件upload

來源:互聯網
上載者:User

我們是利用upload檔案上傳組件進行檔案上傳哦。

<%Server.ScriptTimeOut=5000%>
<!--#include file="conn.asp"-->
<!--#include FILE="upload_5xsoft.inc"-->
<html>
<head>
<title>檔案上傳</title>
<link rel="stylesheet" href="<%=css%>" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body>
<%dim upload,file,formName,formPath,iCount,exeec,wjm
set upload=new upload_5xsoft
formPath="FJ/"

ly=upload.form("content")
yhm=upload.form("yhm")
zid=upload.form("zid")
ys=upload.form("ys")
yyzm = upload.form("yzm")
zt=upload.form("zt")
ztid=upload.form("ztid")
cz=upload.form("cz")
tp=upload.form("tp")
if tp = "http://" then tp = ""
ly=xrzh(ly)

if cz = "" then
 fhlj = "bbs_list.asp?zid="&zid
else
 fhlj = "bbs_tj.asp?page=1000&zt="&zt&"&ztid="&ztid&"&zid="&zid
 zid = ztid
end if

if yyzm <> session(sessionvalue & "yzm") then redirect fhlj

zhhf = jdsj
if yhm = "" then yhm = "遊客"''request.servervariables("remote_addr")

for each formName in upload.objFile ''列出所有上傳了的檔案
 set file = upload.file(formName)
 if file.FileSize>0 then
  kzm = lcase(right(file.filename,4))
  if instr(",.mpg.asf.avi.mp3.swf.mpeg.png.gif.bmp.jpg.wma.wmv.txt",kzm)<= 0 then response.Redirect hflj
  if file.filesize > 819200 then%>
  <script language="javascript">
  alert("檔案大於800k!");
  window.location="<%=fhlj%>";
  </script>
  <%end if
  wjdx = file.filesize
  wjm = formpath&replace(cstr(date),"-","") & cstr(Replace(Timer(), ".", "")) & kzm
  file.SaveAs Server.mappath(wjm)
  dx = cstr(file.filesize/1024)
  if len(dx) >6 then dx=left(dx,6)
 end if
next
if trim(zt) <>"" then
sql = "select * from yrwl_tb_lt order by id desc"
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if sjk <> "" then
 if rs.eof then
  id = "1"
 else
  id = cstr(rs("id")+1)
 end if
end if
rs.addnew
if sjk = "" then
 if rs.eof then
  id = "1"
 else
  id = cstr(rs("id"))
 end if
end if
rs("yhm") = yhm

rs("zt") = zt
rs("ly") = ly

if wjm = "" and tp <> "" then wjm = tp
rs("fj") = wjm
rs("dx") = dx
rs("dj") = 0
rs("zd") = "5"
rs("hf") = 0
if cz = "" then
 rs("zid") = "s"
 rs("zhhf") = jdsj & "   "&yhm
 rs("lb") = zid
else
 rs("zid") = zid
 sql = "select * from yrwl_tb_lt where id=" & zid
 set rs1 = server.createobject("adodb.recordset")
 rs1.open sql,conn,1,3
 rs1("zhhf") = jdsj & "   "&yhm
 rs1.update
 rs1.close
end if

rs("sj") = jdsj
rs.update
rs.close

if instr(yhm,".") = 0 and yhm <> "遊客" then
 exec="select * from yrwl_tb_admin where yhm='"&yhm&"'"
 rs.open exec,conn,3,3
 cs = rs("cs")
 qm = rs("qm")
 if isnull(cs) then cs = 0
 if cs="" then cs=0
 exec="update yrwl_tb_admin set cs=" & cstr( cs + 3 ) & " where yhm='" & yhm & "'"
 conn.execute exec
end if

if  cz = "" then
''讀檔案
 if wjm <> "" then
  kzm = lcase(right(wjm,3))
  if instr(wjm,"http") = 0 then wjm = "../" & wjm
  xswjm = gqzh(wjm)
  if len(wjm)>4 and instr(wjm,"FJ")>0 then
   tpxs = xswjm &  "<br>附件下載:<a href=" & wjm & " target=_blank>[" & wjm &"]</a>"
  else
   tpxs = xswjm
  end if
  if tpxs = "" or (instr(wjm,"swf")>0) then tpxs = "<iframe id=kj name=kj frameborder=0 width=100% height=500 src="&wjm&"></iframe>"
 end if
 
 set fso = Server.Createobject("Scripting.FileSystemObject")
 set file=fso.opentextfile(Server.mappath("tbtb.txt"),1,False)
 do while file.AtEndOfStream<>true
  wjnr = wjnr & file.ReadLine() & chr(13)
 loop
 file.close
 set file = nothing
 set fso = nothing
 if isnull(qm) then qm = ""
 ly = replace(ly,chr(13),"<br>")
 wjnr = replace(wjnr,"$ti$",zt)
 wjnr = replace(wjnr,"$sj$",jdsj)
 wjnr = replace(wjnr,"$zt$", kill_keyword(zt))
 wjnr = replace(wjnr,"$ly$", kill_keyword(ly) & "<br>" & tpxs & "--------------------------------------<Br> 個性簽名:<a title="&qm&">"&qm&"</a>")
 wjnr = replace(wjnr,"$zid$",zid)
 wjnr = replace(wjnr,"$qm$",qm)
 wjnr = replace(wjnr,"$ztid$",id)

 if instr(yhm,".")>0 then yhm=left(yhm,instrrev(yhm,"."))&"*"
 wjnr = replace(wjnr,"$fyr$",yhm)
 wjnr = replace(wjnr,"$lxfs$",session(sessionvalue & "lxfs"))
''寫檔案
 wj = Server.mappath( "tb/" & id & ".htm" )
 set myfileobject=server.CreateObject("Scripting.FileSystemObject")
 set mytextfile=myfileobject.CreateTextFile(wj)
 mytextfile.WriteLine wjnr
 mytextfile.close
end if

set file=nothing
set upload=nothing  ''刪除此對象
end if
conn.close
response.redirect fhlj%>
</body>
</html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.