upload.asp
<form action=http://<%= Request. ServerVariables(SERVER_NAME)>/wdread.asp method=post>
<p>主题: <input type=text name=subject><br>
作者:<input name=author type=text><br>
发布时间: <input name=date1 type=text><br>
上载文件:<input type=file name=filename>
发往URL: <input type=hidden name=TargetURL value=http://<%= Request.ServerVariables(SERVER_NAME)%>/users/<%=Request.ServerVariables(LOGON_USER) %> size=20><br>
<input type=submit value=确定> </p>
</form>
wdread.asp
<form enctype=multipart/form-data action=http://<%= Request.ServerVariables (SERVER_NAME) %>/scripts/cpshost.dll?PUBLISH?wdwriter.asp method=post name=form1>
上载文件:<input type=file name=filename value=<%=session(filename)%>>
<input type=hidden name=TargetURL value=http://<%= Request.ServerVariables (SERVER_NAME) %>/users/wdls >
<input type=button name=upload value=确定>
</form>
<scripts language=VBScript>
' 在上载时应对表单域filename的值与upload.asp程序中的域值进行比较, 因为在upload.asp中输入的文件名在本程序中预置给表单域filename,一旦客户端重新输入新的文件名后提交确认,会使程序wdwriter.asp中写入数据库的文件名与实际上载的文件名不一样, 导致网页连接出错.此处进行判断,如果两者相等,则立即上载,否则取消操作.
<!--
sub upload_onclick()
set myform=window.document.form1
tmp=myform.filename.value
if strcomp(tmp,<%=session
(filename)%>)=0 then
form1.submit
else
msgbox 噢,您输入的文件名有误,请重新输入!
end if
end sub
-->
</scripts>
wdwriter.asp
<%
Set mydata = Server.CreateObject (ADODB.Connection) mydata.Open DSN=xczh;UID=sa;PWD=;
' 打开数据库.
date1=session(date1)
' 取各表单域的值.取时间.
subject=session(subject)
' 取文件主题.
author=session(subject)
' 取作者.
filename=session(filename)
' 取文件名.
TargetURL= session(TargetURL)
' 取文件在服务器中存放的物理地址.
sqlstr=insert into wdlsb values( & sn & ,& subject & ', & date1 & ',&filename & ', & TargetURL &', & author & ')
' 写数据库并保存.
Mydata.Execute(sqlstr)
%>
[1]
本文章来源于网络,作者是:,由代码部落进行采编,如涉及侵权请联系删除!转载请注明出处:https://daimabuluo.cc/biancheng10000wen/1120.html