上传的代码为:
if upfile.postedfile is nothing then
msg.text="请选择文件!"
exit sub
else
dim temp() as string=split(upfile.postedfile.filename,"\")
fname=temp(temp.length-1)
try
upfile.postedfile.saveas(server.MapPath("../source/")+"\"+fname)
catch ex as exception
outbyfile(ex.tostring())
msg.text="文件上传失败,请重试!"
exit sub
finally
end try
end if
下载的代码:
<script language="vb" runat="server">
sub page_load(obj as object,evt as eventargs)
dim filename as string
if request("name")="" or not(file.exists(server.mappath("../source/"+request("name")))) then
response.write("你的请求数据有误!")
exit sub
else
filename=request("name")
end if
'-----------------------------------------------------------------------
dim s as filestream
try
s=file.openread(server.mappath("../source/"+filename))
dim bufsize as short=2048
dim buf(bufsize) as byte
while s.read(buf,0,bufsize)>0
response.binarywrite(buf)
end while
catch ex as exception
outbyfile(ex.tostring())
response.write("你的请求数据有误!")
finally
s.close()
end try
'------------------------------------------------------------------------
response.end()
end sub
上传的代码为:
if upfile.postedfile is nothing then
msg.text="请选择文件!"
exit sub
else
dim temp() as string=split(upfile.postedfile.filename,"\")
fname=temp(temp.length-1)
try
upfile.postedfile.saveas(server.MapPath("../source/")+"\"+fname)
catch ex as exception
outbyfile(ex.tostring())
msg.text="文件上传失败,请重试!"
exit sub
finally
end try
end if