savenews.asp

来自「就业信息服务网」· ASP 代码 · 共 84 行

ASP
84
字号
<%OPTION EXPLICIT%>
<!--#include FILE="upload_5xsoft.inc"-->
<!--#include file="conn.asp"-->
<link rel="stylesheet" type="text/css" href="../../../cwtw/manag/main.css">
<body bgcolor="#4473A5" marginheight=0 marginwidth=0 leftmargin=0>
<html>
<body>
<%
dim upload,file,formName,formPath,iCount,title,typeid,tjnews,content,selectpic,from,picurl,rs
set upload=new upload_5xSoft
formPath=upload.form("filepath")
if right(formPath,1)<>"/" then formPath=formPath&"/" 
title=upload.form("title")
typeid=upload.form("typeid")
content=upload.form("content")
nfrom=upload.form("from")
selectpic=upload.form("selectpic")
typename=upload.form("typename1")
tjnews=upload.form("tjnews")
picurl=upload.form("picurl")

dim sql1
dim rs1
dim typename1
sql1="select * from newstype where typeid="&typeid
set rs1=server.createobject("adodb.recordset")
rs1.open sql1,conn,1,1
typename1=rs1("type")

if upload.form("checkbox1")="1" then
 tjnews=1
else
 tjnews=0
end if
content=upload.form("content")
from=upload.form("from")
if upload.form("checkbox3")="1" then
  selectpic=1
else
  selectpic=0
end if
iCount=0
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName)  ''生成一个文件对象
if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
    if file.filesize>150000 then
       HtmEnd "您上传的文件大于规定大小(20K),请改变文件大小后再进行上传。"
    else
       if trim(right(file.FileName,3))<>"jpg" and trim(right(file.FileName,3))<>"gif" then
          HtmEnd "您上传的文件GIF或JPG图象文件,请将你上传的文件转换此格式后再进行上传。"
       else
          file.SaveAs Server.mappath(formPath&file.FileName)   ''保存文件
          picurl=file.FileName
          iCount=iCount+1
      end if
    end if
end if
set file=nothing
next
set rs=server.CreateObject("ADODB.RecordSet")
rs.open "select * from news",conn,3,2
rs.addnew
rs("title")=title
rs("content")=content
rs("nfrom")=from
rs("selectpic")=selectpic
rs("typeid")=typeid
rs("typename")=typename1
rs("tjnews")=tjnews
rs("picurl")=picurl
rs.update
rs.close
set rs=nothing
conn.close
set upload=nothing  ''删除此对象
Htmend iCount&" 个文件上传结束!"
sub HtmEnd(Msg)
 set upload=nothing
 response.write "<br>"&Msg&" [<a href=""javascript:history.back();"">返回</a>]</body></html>"
 response.end
end sub
%>
</body>
</html>

⌨️ 快捷键说明

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