上传文件
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
**************************************************************************
%>
