ASP using File Upload component upload

Source: Internet
Author: User
Tags chr file upload

We are using upload file upload components for file upload Oh.

<%Server.ScriptTimeOut=5000%>
<!--#include file= "conn.asp"-->
<!--#include file= "Upload_5xsoft.inc"-->
<title> File Upload </title>
<link rel= "stylesheet" href= "<%=css%>" type= "Text/css" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "><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 = "Visitor" ' Request.ServerVariables ("REMOTE_ADDR")

For every formName in Upload.objfile ' lists all uploaded files
 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 ("File greater than 800k!");
  window.location= "<%=fhlj%>";
  </SCRIPT>
  <%end if
  WJDX = file.filesize
  WJM = Formpath&replace (c STR (date), "-", "" "& CStr (Replace (Timer (),". "," ")) & KZM
  file. SaveAs Server.MapPath (WJM)
  DX = CStr (file.filesize/1024)
  If Len (dx) >6 then Dx=left (dx,6)
&nb Sp;end if
Next
If Trim (ZT) <> "then
sql =" SELECT * from YRWL_TB_LT ORDER BY id DESC "
Set rs = Serv Er.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
en D if
rs.addnew
If SJK = "" Then
 if rs.eof then
  id = "1"
 else
  ID = CStr (r S ("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 <> "visitors" then
 exec= "SELECT * from Yrwl_tb_admin where yhm= '" "
 rs.open exec,conn,3,3
 cs = RS ("cs")
&NBSP;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 &" "
&nbs P;conn.execute exec
End If

if  CZ = "Then
" read file
 if wjm <> "" then
  KZM = LCase (Right (wjm,3))
  IF in STR (WJM, "http") = 0 Then wjm = ". /"& WJM
  XSWJM = Gqzh (WJM)
  If Len (WJM) >4 and InStr (WJM," FJ ") >0 then
   tpxs = XSWJM &  "<br> attachment download: <a href=" & WJM & "target=_blank>[" & WJM & "]</a>"
&N Bsp 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
& nbsp
 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 (a)
 loop
 file.close
 set file = Nothing
 set fso = Nothing
 if IsNull (QM) Then QM = ""
 ly = replace (LY,CHR (), <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> personality Signature: <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"))
"Write the file
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 ' Deletes this object
End If
Conn.close
Response.Redirect fhlj%>
</body>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.