⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upload.asp

📁 淘客网上商店网站程序 淘客网上商店网站程序 淘客网上商店网站程序
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<!--#include file = "../Conn.asp"-->
<!--#include file = "../Inc/Cl_ClsSysTem.asp"-->
<!--#include file = "../Inc/Cl_ClsUpFile.asp"-->
<%
Cl.Page_Admin	= True
Cl.Get_WebSetting()
if Not Cl.ChkUserLogin then
	Call Cl.OutErr(0,"<br /><li>您无此操作权限!</li>")
end if
Server.ScriptTimeOut = 999999
' 参数变量
Dim sType, sStyleName, sTrSetting
Dim sChannelID, IsTrueUpfiles 
'频道ID,允许上传权限
' 设置变量
Dim sAllowExt, nAllowSize, sIsReName, sUploadDir, sPreviewpath, nUploadObject, nAutoDir, sBaseUrl, sContentPath
' 接口变量
Dim sFileExt, oFileSize, sOriginalFileName, sSaveFileName, sPathFileName, nFileNum

dim strJs
Dim Upload,FormName,FilePath,ChildFilePath
Dim File,F_FileName,F_ViewName,F_Filesize,F_FileExt,F_Type
Dim DrawInfo
Dim sTObj
Dim sAction
sAction		= UCase(Trim(Request.QueryString("action")))
Call InitUpload()		' 初始化上传参数
Select Case sAction
Case "REMOTE"
	Call DoRemote()			' 远程自动获取
Case "SAVE"
	Call ShowForm()			' 显示上传表单
	Call DoSave()			' 存文件
Case Else
	Call ShowForm()			' 显示上传表单
End Select

Sub ShowForm() 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>文件上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
body, a, table, div, span, td, th, input, select{font:9pt;font-family: tahoma, 宋体, fantasy;}
body {padding:0px;margin:0px}
</style>
<script language="JavaScript" src="dialog/dialog.js" type="text/javascript"></script>
</head>
<body bgcolor="menu">
<form action="Upload.asp?action=save&amp;cid=<%=sChannelID%>&amp;type=<%=sType%>&amp;style=<%=sStyleName%>&amp;TObj=<%=sTObj%>" method="post" enctype="multipart/form-data" name="myform" id="myform">
	<input type="file" name="uploadfile" size="1" style="width:100%" onchange="originalfile.value=this.value;SelectOnchange(this.value);" />
	<input type="hidden" name="originalfile" value="" />
</form>
<script language="JavaScript" type="text/javascript">
var oForm = document.myform ;
var sAllowExt = "<%=sAllowExt%>";
// 提交事件加入检测表单
oForm.attachEvent("onsubmit", CheckUploadForm) ;
if (! oForm.submitUpload) oForm.submitUpload = new Array() ;
oForm.submitUpload[oForm.submitUpload.length] = CheckUploadForm ;
if (! oForm.originalSubmit) {
	oForm.originalSubmit = oForm.submit ;
	oForm.submit = function() {
		if (this.submitUpload) {
			for (var i = 0 ; i < this.submitUpload.length ; i++) {
				this.submitUpload[i]() ;
			}
		}
		this.originalSubmit() ;
	}
}
<%if Not Cl.ChkUserGroupID(IsTrueUpfiles,Cl.UserGroupID) then%>
parent.d_checkfromfile.checked=false;
parent.d_checkfromfile.disabled=true;
parent.d_checkfromurl.checked=true;
parent.d_fromurl.disabled=false;
oForm.uploadfile.disabled=true;
<%else%>
// 上传表单已装入完成
try {
	parent.UploadLoaded();
}
catch(e){
}
<%end if%>
function SelectOnchange(sfile){
	var sType = "<%=sType%>";
	if ((IsExt(sfile,'gif|bmp|jpg|png')) && (sType=="IMAGE")){
		parent.doPreview();
	}
}
// 检测上传表单
function CheckUploadForm() {
	if (!IsExt(document.myform.uploadfile.value,sAllowExt)){
		parent.UploadError("提示:\n\n请选择一个有效的文件,\n支持的格式有("+sAllowExt+")!");
		return false;
	}
	return true
}
</script>
</body>
</html>
<% 
End Sub 

' 保存操作
Sub DoSave()
	'判断上传文件权限
	if Not Cl.ChkUserGroupID(IsTrueUpfiles,Cl.UserGroupID) then
		OutScript("parent.UploadError('本频道上传功能已禁用或者你无上传文件权限!')")
		Response.end
	end if
	Set Upload = New UpFile_Cls
	InitUpLoad_Cls
	Upload.SaveUpFile
	If Upload.ErrCodes<>0 Then
		Call OutScript("parent.UploadError('错误:"& Upload.Description &"')")
		Response.End
	End If
	strJs=""
	On Error Resume Next
	If Upload.Count > 0 Then
		For Each FormName In Upload.UploadFiles
			Set File = Upload.UploadFiles(FormName)
			sSaveFileName = File.FileName
			F_FileName = sUploadDir & sSaveFileName
			sPathFileName = sContentPath & sSaveFileName
			'创建预览及水印图片
			If Upload.PreviewType<>999 and File.FileType=1 then
				F_Viewname = sPreviewpath & "pre" & Replace(File.FileName,File.FileExt,"") & "jpg"
				Upload.CreateView F_FileName,F_Viewname,File.FileExt
			End If
			strJs=strJs&"parent.UploadSaved('" & sPathFileName & "');var obj=parent.dialogArguments.dialogArguments;if (!obj) obj=parent.dialogArguments;try{obj.addUploadFile('" & File.OldFileName & "', '" & sSaveFileName & "', '" & sPathFileName & "');"'} catch(e){};"
			if Lcase(left(sPathFileName,Len(Cl.UpLoadDir)))=Lcase(Cl.UpLoadDir) then
				sPathFileName="{$uploaddir}" & mid(sPathFileName,Len(Cl.UpLoadDir)+1) 
			elseif left(sPathFileName,1)="/" then
				sPathFileName="{$webdir}" & mid(sPathFileName,2)
			else
				sPathFileName=Trim(sPathFileName)
			end if
			strJs=strJs & "obj.AddUploadFiles('"&sTObj&"','" & sPathFileName & "','" & sPathFileName & "');} catch(e){};"
			Cl.InToColumn "Cl_UpFileLog","UserID,UserName,UserGroupID,UserIP,UpFileName,SaveFileName,UpFileTime,ChannelID,IsUse","'"&Cl.UserID&"','"&Cl.MemberName&"','"&Cl.UserGroupID&"','"&Cl.UserTrueIP&"','"&File.OldFileName&"','"&sPathFileName&"','"&Now&"',"&sChannelID&",0"
			Set File = Nothing
		Next
		Call OutScript(strJs)
	Else
		Call OutScript("parent.UploadError('请正确选择要上传的文件。')")
		Response.End
	End If
	Set Upload = Nothing

End Sub

' 自动获取远程文件
Sub DoRemote()
	'判断上传文件权限
	if Not Cl.ChkUserGroupID(IsTrueUpfiles,Cl.UserGroupID) then
		OutScriptNoBack("alert('本频道上传功能已禁用或者你无上传文件权限!');parent.remoteUploadOK();")
		Response.end
	end if
	Dim sContent, i
	For i = 1 To Request.Form("Editor_UploadText").Count 
		sContent = sContent & Request.Form("Editor_UploadText")(i) 
	Next
	If sAllowExt <> "" Then
		sContent = ReplaceRemoteUrl(sContent, sAllowExt)
	End If

	Response.Write "<HTML><HEAD><TITLE>远程上传</TITLE><meta http-equiv='Content-Type' content='text/html; charset=gb2312'></head><body>" & _
		"<input type=hidden id=UploadText value=""" & inHTML(sContent) & """>" & _
		"</body></html>"

	Call OutScriptNoBack("parent.setHTML(UploadText.value);try{parent.addUploadFile('" & sOriginalFileName & "', '" & sSaveFileName & "', '" & sPathFileName & "');} catch(e){} parent.remoteUploadOK();")

End Sub
' 输出客户端脚本
Sub OutScript(str)
	Response.Write "<script type=""text/javascript"">" & str & ";history.back()</script>"
End Sub
Sub OutScriptNoBack(str)
	Response.Write "<script type=""text/javascript"">" & str & "</script>"
End Sub

' 初始化上传限制数据
Sub InitUpload()

	sType		= UCase(Trim(Request.QueryString("type")))
	sTObj		= Trim(Request.QueryString("TObj"))
	sChannelID	= Trim(Request.QueryString("cid"))
	if Not IsNumeric(sChannelID) or sChannelID="" then
		OutScript("alert('错误,请通过页面上的链接进行操作!');window.close();")
		Response.end
	end if
	Cl.Load_ChannelSetting(sChannelID)
	sStyleName		= Cl.Checkstr(Trim(Request.QueryString("style")))
	sTrSetting		= Split(Cl.Channel.selectSingleNode("@uploadsetting").text,"@")
	IsTrueUpfiles	= Trim(sTrSetting(0))		'允许上传权限
	sUploadDir		= Trim(sTrSetting(1))        '上传目录
	nAutoDir		= Cint(sTrSetting(2))			'自动分类 0不使用,1按年,2年-月,3年-月-日
	sPreviewpath	= Replace(Cl.UpLoadDir & "/PreviewImage/" & sUploadDir & "/","//","/")
	sUploadDir		= Replace(Cl.UpLoadDir & "/" & sUploadDir & "/","//","/")
	sUploadDir		= Cl.CreatePath(sUploadDir,nAutoDir)
	sPreviewpath	= Cl.CreatePath(sPreviewpath,nAutoDir) '按年月分类目录
	sContentPath	= sUploadDir'Cl.RelativePath2RootPath(sUploadDir)
	if sTrSetting(3)="1" then
		sContentPath = Cl.RootPath2DomainPath(sContentPath)
	end if
	Select Case sType
	Case "FILE"

⌨️ 快捷键说明

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