请教高手:服务器端文件上载的问题

zjg791015 2003-07-02 03:56:07
<form enctype="multipart/form-data" method="post" name="form1" action="http://<%=Request.ServerVariables("SERVER_NAME")%>/scripts/cpshost.dll?PUBLISH?http://<%=Request.ServerVariables("SERVER_NAME")%>/<%=Application("EOE_APPNAME")%>/workflow_ex/upload/uploadwork.asp" onsubmit="javascript:return check();">

这是小弟近日在研究的一套OA系统的文件上载程序(技术不过关,只能研究一下),我想知道上面action=中的<%=Request.ServerVariables("SERVER_NAME")代表什么?我一直没有搞懂!请高手给予指点,我一定加分。

先谢谢了!我在下面把源文件贴出来,请高手给小弟讲解清楚一点:

选择文件的页面:UpFile.asp
*******************************************************
<%@ Language=VBScript %>
<%Response.Expires=0%>
<%


Dim DesDir,DesDirUpload
Dim fso
Dim file_path

session("eoe_userid") = Request.QueryString("user_id") '避免session丢失!
session("eoe_username") = Request.QueryString("user_name")


DesDir="upload\"&session("eoe_userid")
file_path= Server.MapPath("/"&Application("EOE_APPNAME"))
DesDir=file_path&"\"&DesDir
'Response.Write DesDir
'Response.End

set fso=server.CreateObject ("scripting.filesystemobject")

if not fso.FolderExists(DesDir) then
fso.CreateFolder DesDir
end if
set Fso=nothing

DesDirUpload="http://"&Request.ServerVariables("SERVER_NAME")&"/"&Application("EOE_APPNAME")&"/upload/"&session("eoe_userid")

%>
<html>
<title>我的工作-上传附件</title>
<head>
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0" content="text/html; charset=gb2312">
<link rel="stylesheet" href="<%=SESSION("EOE_USER_CSS")%>">
<script language="javascript" src="../function/funlib.js"></script>
</head>
<script language="javascript">
function check(){
if (document.form1.file.value==""){
alert("请选择要上传的文件!");
return false;
}
}
</script>
<body>
<br>
<form enctype="multipart/form-data" method="post" name="form1" action="http://<%=Request.ServerVariables("SERVER_NAME")%>/scripts/cpshost.dll?PUBLISH?http://<%=Request.ServerVariables("SERVER_NAME")%>/<%=Application("EOE_APPNAME")%>/workflow_ex/upload/uploadwork.asp" onsubmit="javascript:return check();">
<table width="90%" border="0" cellspacing="0" cellpadding="1" align="center">
<tr>
<td width="33%">简单描述</td>
<td width="67%">
<input type="text" name="title" class="ctinput">
可不填 </td>
</tr>
<tr>
<td width="33%">选择文件</td>
<td width="67%">
<input type="hidden" name="TargetURL" value="<%=DesDirUpload%>">
<input type="hidden" name="user_id" value="<%=Request.QueryString("user_id")%>">
<input type="hidden" name="user_name" value="<%=Request.QueryString("user_name")%>">
<input type="file" name="file" class="ctinput">
</td>
</tr>
<tr>
<td height="2" width="33%">
<div align="center">
<input type="submit" name="Upload" value="确定" class="ctinput">
</div>
</td>
<td height="2" width="67%">
<div align="center">
<input type="button" value="取消" name="reset" class="ctinput" onclick="javascript:window.close()">
</div>
</td>
</tr>
</table>
</form>
<p> </p>

</body>
</html>
*******************************************************

处理的页面:UpFeleSv.asp
*******************************************************
<%@ LANGUAGE = VBScript %>

<%
'**********************************************************************************
'引用 :inc/workflow/dbconnection.asp
'处理逻辑:将上传到历史目录的文件改名移动到eoe/upload/user_id目录下
'本页函数/过程列表及说明:
' ConnOpenNewConnection() :返回一条新的数据库连接
' chLk(日期) 把日期转换为字符串
'**********************************************************************************
'// 正文开始
dim sourcefilename,fso
dim datstr
dim sou_file_path,des_file_path
dim upload_file_name

'Session失效处理
session("eoe_userid")=Request.Form("user_id") '必须这样!
session("eoe_username")=Request.Form("user_name")

if session("eoe_userid")="" then
Response.Write "<html><head><meta http-equiv='Content-Language' content='zh-cn'>"
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>"
Response.Write "<link rel='stylesheet' href='"&Session("EOE_USER_CSS")&"'><BODY><table><tr><td>"
Response.Write "请重新登录后再使作!点<a href='/"&Application("EOE_APPNAME")&"'>这里</a>返回重新登录."
Response.Write "</td></tr></table></body></html>"
Response.End
end if

strsubject=Request.Form("title")

'得到源文件路径名和目标文件路径名
SourceFileName = Request.Form("FileName")&Request.Form("FileExtenTion")
datStr=Year(date)& chLk(Month(date))& chLk(day(date))& chLk(Hour(time))& chLk(Minute(time))& chLk(Second(time))
Upload_file_name=datStr&session("eoe_userid")&Request.Form("FileExtenTion")
sou_file_path= Server.MapPath("../../upload")&"\"&session("eoe_userid")&"\"&SourceFileName
des_file_path= Server.MapPath("../../document/workflow")&"\"&Upload_file_name

'Response.write sou_file_path&"<br>"
'Response.write des_file_path
'Response.End
Set fso =CreateObject("Scripting.FileSystemObject")

'文件换名复制!"

fso.CopyFile sou_file_path,des_file_path
fso.DeleteFile sou_file_path,True

'获得显示字符串

if strsubject="" then
strsubject=SourceFileName
end if

function chLk(str)
if len(str)=1 then
chLk="0"&str
else
chLk=str
end if
end function

Set fso=nothing

'Response.Write "<script language=javascript>"&chr(13)
'Response.Write "alert(""上传成功!"");"&chr(13)
'Response.Write "window.opener.newwork.file_des.value="""&strsubject&""";"&chr(13)
'Response.Write "window.opener.newwork.file_name.value="""&upload_file_name&""";"&chr(13)
'Response.Write "if (window.opener.newwork.file_des.value=="")
'Response.Write "window.opener.newwork.file_des.value=window.opener.newwork.file_des.value+"","&strsubject&""";"&chr(13)
'Response.Write "window.opener.newwork.file_name.value=window.opener.newwork.file_name.value+"","&upload_file_name&""";"&chr(13)

' Response.Write "window.opener.newwork.del_file.disabled=false;"
' Response.Write "window.opener.newwork.upload_file.disabled=true;"
' response.Write "window.close();"
'Response.Write "</script>"
'Response.end


%>
<form name="temp" >
<input type=hidden name="subject" value=<%=strsubject%> >
<input type=hidden name="filename" value=<%=upload_file_name%> >
</form>
<script language=javascript>
alert("上传成功!");

if (window.opener.form_main.file_des.value=="")
{ //alert(document.temp.filename.value);
window.opener.form_main.file_des.value=document.temp.subject.value;
window.opener.form_main.file_name.value=document.temp.filename.value;
}
else
{ //alert(document.temp.filename.value);
window.opener.form_main.file_des.value=window.opener.form_main.file_des.value+","+document.temp.subject.value;
window.opener.form_main.file_name.value=window.opener.form_main.file_name.value+","+document.temp.filename.value;
}
window.opener.form_main.del_file.disabled=false;
window.opener.form_main.upload_file.disabled=true;
window.close();
</script>
*******************************************************
...全文
42 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
coffee_cn 2003-07-02
  • 打赏
  • 举报
回复
sh.ce.net.cn/web8/tools/up.zip
zjg791015 2003-07-02
  • 打赏
  • 举报
回复
可我在上传文件老是提示“内部服务器错误”,并不能顺利的把文件上传到服务器,该程序中用到的DLL文件已在服务器中注册,请高手帮忙告之!

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧