上传文件
1.上传页面
<form name="FORM" action="upLoad.asp" method="post">
<input type="submit" name="submit" value="OK">
<input type="file" name="file1" style="width:400" value="">
</form>
2.数据上传操做 (upLoad.asp) 页面
<% language=VBScript %>
<%
call upLoad
'**********************************************************************
Private Function getFileName(ByVal strFile)
'本函数用来取得上传文件名称
If strFile <> "" Then
getFileName = mid(strFile,InStrRev(strFile, "\")+1)
Else
getFileName = ""
End If
End function
'************************************************************************
private sub upLoad()
on error resume next
'用来执行上传文件的代码
strFileName = Request.Form("file1")
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = 1 ' adTypeBinary
objStream.Open
objStream.LoadFromFile strFileName
'保存文件到服务器
objStream.SaveToFile "D:\download\" & getFileName(strFileName),2
objStream.Close
if err = 0 then
response.write "上传成功!"
else
response.write "上传失败!"
end if
set objStream = nothing
End Sub
'**************************************************************************
%>