无组件上传到特定文件夹,并自动重命名,怎样实现

我用的稻香老农的无组件上传,要根据用户在一个表单里填写的内容和用户在下拉菜单中选择的项目重命名上传的文件。

例如,用户在表单中添写用户名 1234 在下拉菜单中选择 admin
则将他上传的文件重命名为 1234admin.zip

请给出代码,谢谢了
---------------------------------------------------------------

newfilename = request("username")&request("selectadmin")&".zip"

找到保存文件的地方替换一下。

稻香老农无组件上传我没用过,不知道上面是不是回答正确。
---------------------------------------------------------------

file.saveas mappath("/" & path & "" & filename)
filename path 你定义好了
---------------------------------------------------------------

newfilename = request.form("username")&request.form("selectadmin")&".zip"
---------------------------------------------------------------

真正无组件

1<head>
2<meta content="zh-cn" http-equiv="Content-Language"/>
3<meta content="Microsoft FrontPage 5.0" name="GENERATOR"/>
4<meta content="FrontPage.Editor.Document" name="ProgId"/>
5<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
6<link href="font.css" rel="stylesheet" type="text/css"/>
7</head>
1<body>   

dim contentlen
contentlen=request.totalbytes

if contentlen&gt;102400 then
response.write "文件太大,超过100k,不允许上传。请返回"
else

dim content
content=request.binaryread(request.totalbytes)

'二进制相互转换
Function getByteString(StringStr)
getByteString=""
For i=1 to Len(StringStr)
char=Mid(StringStr,i,1)
getByteString=getByteString&amp;chrB(AscB(char))
Next
End Function
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString &amp; chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function

dim upbeg,upend,lineone,linetwo,linethree,line1,line2,line3
upbeg=1
upend=instrb(upbeg,content,getbytestring(chr(10)))
lineone=midb(content,upbeg,upend-upbeg)
upbeg=upend+1
line1=lenb(lineone)
upend=instrb(upbeg,content,getbytestring(chr(10)))
linetwo=midb(content,upbeg,upend-upbeg)
upbeg=upend+1
line2=lenb(linetwo)
upend=instrb(upbeg,content,getbytestring(chr(13)))
linethree=midb(content,upbeg,upend-upbeg)
line3=lenb(linethree)

'获得文件名
dim pp,checknametemp,checklen,checkname,filename
pp=instrb(1,linetwo,getbytestring(chr(46)))
checknametemp=rightb(linetwo,line2-pp+1)
checklen=instrb(1,checknametemp,getbytestring(chr(34)))
checkname=getstring(leftb(checknametemp,checklen-1))
filename=year(now)&amp;month(now)&amp;day(now)&amp;hour(now)&amp;minute(now)&amp;second(now)&amp;checkname

'上传文件
dim alllen,upstream,upstreamend,file
alllen=line1+line2+line3+6
set upstream=server.createobject("adodb.stream")
set upstreamend=server.createobject("adodb.stream")
upstream.type=1
upstreamend.type=1
upstream.open
upstreamend.open
upstream.write content
upstream.position=alllen
file=upstream.read(clng(contentlen-alllen-line1-5))
upstreamend.write file
upstreamend.savetofile(server.mappath("news/pic/"&amp;filename))
upstream.close
upstreamend.close
set upstream=nothing
set upstreamend=nothing

response.write("已上传")
end if

1</body>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus