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

📄 t_photo.asp

📁 物业管理和办公自动化系统
💻 ASP
字号:
<%
'************************************************************************************************
' 文件名: t_photo.asp
' Copyright(c) 2001-2002 上海阿尔卡特网络支援系统有限公司
'
'  创建人 : 周秋舫
'  日 期 : 2002-05-13
' 修改历史 :
'   ****年**月**日 ****** 修改内容:**************************************************
' 功能描述 : 员工照片
'  版 本 :
'*******************************************************************************
option explicit
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
%>

<!-- #include file="../include/config.inc" -->
<!-- #include file="../include/common.inc" -->
<!-- #include file="../include/debug.inc" -->
<!-- #include file="../include/db.inc" -->
<!-- #include file="../include/date.inc" -->
<!-- #include file="../include/datahandle.inc" -->
<!-- #include file="../include/recordlist.inc" -->
<!-- #include file="../include/security.inc" -->

<!-- #include file="../common/commonpage.inc" -->

<%
'sFileName = "UploadPhoto.asp"
'CheckSecurity(sFileName)


'--------------------------------------------------------------------------------------------------
' 使用Request.Form后不能调用Binary Read,因此这里需覆盖common.asp中的GetParam()函数来获取参数
'--------------------------------------------------------------------------------------------------
function GetParam(ParamName)
	Dim Param : Param = ""
	if Request.QueryString(ParamName).Count > 0 then Param = Request.QueryString(ParamName)
	if Param = "" then Param = Empty
	GetParam = Param
end function
%>

<%
'*******************************************************************************
' 服务器端代码
dim pEmpSerial : pEmpSerial = GetParam("emp_serial")
dim sEmpName				' 员工姓名
dim sPhotoPath				' 上传照片的路径为当前路径下的photo目录, IIS服务器必须设置该目录为可写
dim sSQL, rs, crs

if CStr(GetCoId) <> "1" then
	Response.Write "你不是业主公司的员工"
	Response.end
end if

sPhotoPath = left(Request.ServerVariables("PATH_TRANSLATED"), instrrev(Request.ServerVariables("PATH_TRANSLATED"),"\")) & "photo\"

'--------------------------------------------------------------------------------------------------
' 获取数据Emp_Id和Emp_name
'--------------------------------------------------------------------------------------------------
sSQL = "select emp_id, name as emp_name from t_employee"	& _
	" where serial = " & ToSQL(pEmpSerial, "Number")		& _
	" and co_id = 1 and dismissed = 0"
set crs = New CRecordset
set rs = crs.Open(dbLocal, sSQL)
if rs.eof then
	crs.Close()
	Response.Clear
	Server.Transfer "../common/error.asp"
	Response.end
end if
sEmpName = crs.GetValue("emp_name")
crs.Close()


'--------------------------------------------------------------------------------------------------
' 上传照片
'--------------------------------------------------------------------------------------------------
Dim objUpload
Dim varResult : varResult = ""
if LCase(Request.ServerVariables("REQUEST_METHOD")) = "post" then
	Set objUpload = Server.CreateObject("aspcn.upload")
	objupload.maxsize		= 100000				'  设定文件最大长度不超过100K,默认值为100K
	objupload.overwrite		= 2						'  设定如果目标文件存在,进行覆盖,默认为1,表示不能覆盖
	objupload.path			= sPhotoPath			'  设定上传到服务器的路径,这里必须为绝对路径,默认值为c:\
	objupload.uptofile		= 1						'  此处将uptofile设置为1,表明上传后保存文件(为默认值),2 表示不保存只接收数据
	objupload.newfilename	= pEmpSerial & ".gif"	'  此处设置上传后的文件名,如果设定此值后,一次只能上传一个文件
	varResult				= objUpload.Upload		'  调用upload方法将文件保存

	if varResult = "OK" then						'  如果varResult返回OK,则文件上载成功
		varResult = ""
		'Response.redirect "emp_om.asp?emp_serial=" & pEmpSerial
	else											'上传出错
		varResult = "没成功? 不要紧, 再试试看! 记住照片文件的大小不能超过 100K 哦!"
	end If 
	Set objUpload = Nothing
end if
%>

<html>
<head>
<title>照片上传</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../common/common.css" type="text/css">

<style type="text/css">
.flatBtn {cursor:hand;border:1px outset #000000; font-size: 9pt; background-color:#ddddcc;color:black;}
</style>
</head>

<script language="javaScript">
	var sError = "<%=varResult%>"
	if (sError != "")
		alert(sError);
</script>

<body>

<form name="frmUpload" Method="post" Enctype="multipart/form-data" Action="t_photo.asp?emp_serial=<%=pEmpSerial%>">

<table border=0 id="tblPhoto" height=250 valign=middle align=left>
<tr height=20><td>员工<span style="color:blue"><%=sEmpName%></span>的照片:</td></tr>
<tr height=20><td><input type="file" name="FileName" size=33 style="vertical-align:middle">&nbsp;<input type="image" style="border-width:0;vertical-align:middle" src="../images/button/upload.gif"></td></tr>
<tr height=20><td><span style="color:gray">若您点击[上传照片]后,图片没有更新,请点击</span><a href="javascript:window.location.reload()"><img border=0 src="images/refresh.gif" style="cursor:hand"></a></td></tr>
<tr height="*"><td valign=top><img border=0 src="photo/<%=pEmpSerial%>.gif"></td></tr>
</table>
</form>

</body>
</html>

⌨️ 快捷键说明

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