saveadddowninfo.asp

来自「ASP编写的一个公司网站的源程序」· ASP 代码 · 共 102 行

ASP
102
字号
<%

Response.Buffer = True


%>
<!--#include virtual="/Include/IncSelectConst.asp"-->
<!--#include virtual="/Include/DBConn.asp"-->
<!--#include virtual="/Include/ChkSession.asp"-->
<!--#include virtual="/include/upload_5xsoft.inc"--> 
<!--#include virtual="/Include/FuncPub.asp"-->
<!--#include file="Function.asp"-->
<%
	Dim fileup 
	Set fileup = New upload_5xsoft
	Dim fso
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	Dim rs,StrSQL
	Dim Type_ID,down_title,down_path,down_content,state,down_ID
	Type_ID = ModifyInput(trim(fileup.Form("Type_ID")))
	down_title = ModifyInput(trim(fileup.Form("down_title")))
    down_content = ModifyInput(fileup.Form("down_content"))
	'On Error Resume Next
	Dim fileupimg
	Set fileupimg = fileup.file("down_path")
	down_path = trim(fileupimg.filename)
	If down_path<>"" then
		IF UCASE(GetFileNameExt(down_path))<>"GIF" and UCASE(GetFileNameExt(down_path))<>"JPG" and UCASE(GetFileNameExt(down_path))<>"PDF" then
			Response.Write "<script language='javascript'>"
			Response.Write "alert('对不起!你上传的图片格式只能是GIF或JPG!');"
			Response.Write "window.history.go(-1);"
			Response.Write "</script>"
			Response.End
		End IF
		'If fileupimg.filesize > UPLOAD_IMGMAXFILESIZE then
		'	Response.Write "<script language='javascript'>"
		'	Response.Write "alert('对不起!请将您的文件控制在5M以下!');"
		'	Response.Write "window.history.go(-1);"
		'	Response.Write "</script>"
		'	Response.End
		'End If
	Else
			Response.Write "<script language='javascript'>"
			Response.Write "alert('请上传图片!');"
			Response.Write "window.history.go(-1);"
			Response.Write "</script>"
			Response.End	
	End If
    Set rs = Server.CreateObject("Adodb.Recordset")
    CheckInput
    rs.CursorLocation=3
    StrSQL = "Select * From DownInfo Where down_ID=0" 
    rs.Open StrSQL,conn,1,3 
    rs.AddNew 
		rs("type_ID") = type_ID
		rs("down_title") = down_title
		rs("down_content") = down_content
		rs("state") = state
    rs.Update
		down_ID = rs("down_ID")
    rs.Close
    Conn.Execute "Update DownInfo Set Orderline="&down_ID&" where down_ID="&down_ID&""
    Dim strFullPath
	strFullPath = Request.ServerVariables("APPL_PHYSICAL_PATH")
	if Right(strFullPath,1) = "\" then
		strFullPath = left(strFullPath,len(strFullPath)-1)
	end if
If down_path<>"" then
	if fso.FolderExists(strFullPath & UPLOAD_FILESPATH & Session("CatID") )=False then
		fso.CreateFolder strFullPath & UPLOAD_FILESPATH & Session("CatID")
	end if
	if fso.FolderExists(strFullPath & UPLOAD_FILESPATH & Session("CatID") & "\" & down_ID )=False then
		fso.CreateFolder strFullPath & UPLOAD_FILESPATH & Session("CatID") & "\" & down_ID 
	end if

	fileupimg.SaveAs strFullPath & UPLOAD_FILESPATH & Session("CatID") & "\" & down_ID & "\" & down_path
	
	Photo_Path = Replace(UPLOAD_FILESPATH & Session("CatID") & "\" & down_ID & "\" & down_path,"\","/")
	Conn.Execute "Update DownInfo Set down_path='"&down_path&"' where down_ID="&down_ID&""
End IF	
    If Err.number<>0 then
		Call MsgBack("数据库操作错误!","4")
    Else
		Response.Redirect "DownInfoManage.asp"
    End IF 
    Set rs = Nothing
    
    
Sub CheckInput
	StrSQL="select count(*) as cou from DownInfo where Type_ID="&Type_ID&" and down_title='"&down_title&"'"
	Rs.open StrSQL,conn,1,3 
	If Rs("cou")<>0 then
		Rs.close 
		Call MsgBack("下载文件标题重复!","4")
		exit Sub
	End If
	Rs.Close
End Sub
set fso = Nothing
 Set fileup = Nothing
%>
<!--#include virtual="/Include/DBClose.asp"-->

⌨️ 快捷键说明

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