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>
發(fā)布時間: input name=date1 type=text>br>
上載文件:input type=file name=filename>
發(fā)往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>
' 在上載時應(yīng)對表單域filename的值與upload.asp程序中的域值進(jìn)行比較, 因?yàn)樵?/SPAN>upload.asp中輸入的文件名在本程序中預(yù)置給表單域filename,一旦客戶端重新輸入新的文件名后提交確認(rèn),會使程序wdwriter.asp中寫入數(shù)據(jù)庫的文件名與實(shí)際上載的文件名不一樣, 導(dǎo)致網(wǎng)頁連接出錯.此處進(jìn)行判斷,如果兩者相等,則立即上載,否則取消操作.
!--
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
?。?/SPAN>>
/scripts>
wdwriter.asp
%
Set mydata = Server.CreateObject (ADODB.Connection) mydata.Open DSN=xczh;UID=sa;PWD=;
' 打開數(shù)據(jù)庫.
date1=session(date1)
' 取各表單域的值.取時間.
subject=session(subject)
' 取文件主題.
author=session(subject)
' 取作者.
filename=session(filename)
' 取文件名.
TargetURL= session(TargetURL)
' 取文件在服務(wù)器中存放的物理地址.
sqlstr=insert into wdlsb values( & sn & ,& subject & ', & date1 & ',&filename & ', & TargetURL &', & author & ')
' 寫數(shù)據(jù)庫并保存.
Mydata.Execute(sqlstr)
?。?/SPAN>>
[1]