熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

asp利用文件上傳組件upload

2013-11-13 10:44:32  來源: .NET編程 

  我們是利用upload文件上傳組件進行文件上傳哦

  <%ServerScriptTimeOut=%>
<!#include file="connasp">
<!#include FILE="upload_xsoftinc">
<html>
<head>
<title>文件上傳</title>
<link rel="stylesheet" href="<%=css%>" type="text/css">
<meta httpequiv="ContentType" content="text/html; charset=gb"></head>
<body>
<%dim uploadfileformNameformPathiCountexeecwjm
set upload=new upload_xsoft
formPath="FJ/"

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

  if cz = "" then
 fhlj = "bbs_listasp?zid="&zid
else
 fhlj = "bbs_tjasp?page=&zt="&zt&"&ztid="&ztid&"&zid="&zid
 zid = ztid
end if

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

  zhhf = jdsj
if yhm = "" then yhm = "游客"requestservervariables("remote_addr")

  for each formName in uploadobjFile 列出所有上傳了的文件
 set file = uploadfile(formName)
 if fileFileSize> then
  kzm = lcase(right(filefilename))
  if instr("mpgasfavimpswfmpegpnggifbmpjpgwmawmvtxt"kzm)<= then responseRedirect hflj
  if filefilesize > then%>
  <script language="javascript">
  alert("文件大於k!");
  windowlocation="<%=fhlj%>";
  </script>
  <%end if
  wjdx = filefilesize
  wjm = formpath&replace(cstr(date)"""") & cstr(Replace(Timer() "" "")) & kzm
  fileSaveAs Servermappath(wjm)
  dx = cstr(filefilesize/)
  if len(dx) > then dx=left(dx)
 end if
next
if trim(zt) <>"" then
sql = "select * from yrwl_tb_lt order by id desc"
set rs = servercreateobject("adodbrecordset")
rsopen sqlconn
if sjk <> "" then
 if rseof then
  id = ""
 else
  id = cstr(rs("id")+)
 end if
end if
rsaddnew
if sjk = "" then
 if rseof then
  id = ""
 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") =
rs("zd") = ""
rs("hf") =
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 rs = servercreateobject("adodbrecordset")
 rsopen sqlconn
 rs("zhhf") = jdsj & "   "&yhm
 rsupdate
 rsclose
end if

  rs("sj") = jdsj
rsupdate
rsclose

  if instr(yhm"") = and yhm <> "游客" then
 exec="select * from yrwl_tb_admin where yhm="&yhm&""
 rsopen execconn
 cs = rs("cs")
 qm = rs("qm")
 if isnull(cs) then cs =
 if cs="" then cs=
 exec="update yrwl_tb_admin set cs=" & cstr( cs + ) & " where yhm=" & yhm & ""
 connexecute exec
end if

  if  cz = "" then
讀文件
 if wjm <> "" then
  kzm = lcase(right(wjm))
  if instr(wjm"http") = then wjm = "/" & wjm
  xswjm = gqzh(wjm)
  if len(wjm)> and instr(wjm"FJ")> then
   tpxs = xswjm &  "<br>附件下載:<a href=" & wjm & " target=_blank>[" & wjm &"]</a>"
  else
   tpxs = xswjm
  end if
  if tpxs = "" or (instr(wjm"swf")>) then tpxs = "<iframe id=kj name=kj frameborder= width=% height= src="&wjm&"></iframe>"
 end if
 
 set fso = ServerCreateobject("ScriptingFileSystemObject")
 set file=fsoopentextfile(Servermappath("tbtbtxt")False)
 do while fileAtEndOfStream<>true
  wjnr = wjnr & fileReadLine() & chr()
 loop
 fileclose
 set file = nothing
 set fso = nothing
 if isnull(qm) then qm = ""
 ly = replace(lychr()"<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"")> then yhm=left(yhminstrrev(yhm""))&"*"
 wjnr = replace(wjnr"$fyr$"yhm)
 wjnr = replace(wjnr"$lxfs$"session(sessionvalue & "lxfs"))
寫文件
 wj = Servermappath( "tb/" & id & "htm" )
 set myfileobject=serverCreateObject("ScriptingFileSystemObject")
 set mytextfile=myfileobjectCreateTextFile(wj)
 mytextfileWriteLine wjnr
 mytextfileclose
end if

  set file=nothing
set upload=nothing  刪除此對象
end if
connclose
responseredirect fhlj%>
</body>
</html>


From:http://tw.wingwit.com/Article/program/net/201311/14414.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.