网页ASP制作:上传文件的网页如何设置默认文件名

我的上传文件,上传了之后文件名变成了数字,现在想他上传后显示还是默认文件名,不知要改以下代码的哪个位置:说明:我的这个是将文件上传到指定的文件夹的。upload.asp<... 我的上传文件,上传了之后文件名变成了数字,现在想他上传后显示还是默认文件名,不知要改以下代码的哪个位置:
说明:我的这个是将文件上传到指定的文件夹的。
upload.asp
<%
dim contentlen
contentlen=request.totalbytes
if contentlen>10240000 then
response.write "文件太大,超过10M,不允许上传。请返回"
else
dim content
content=request.binaryread(request.totalbytes)
'二进制相互转换
Function getByteString(StringStr)
For i=1 to Len(StringStr)
char=Mid(StringStr,i,1)
getByteString=getByteString&chrB(AscB(char))
Next
End Function
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & 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)&month(now)&day(now)&hour(now)&minute(now)&second(now)&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("../tupian/lbbs_pic/"&filename))'此处pic改成指定目录下文件夹
upstream.close
upstreamend.close
set upstream=nothing
set upstreamend=nothing
response.write("图片已上传")
end if
%>
应该是改:filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&checkname
如何改呢,变回原来的文件名。
展开
 我来答
云水季洋
2011-04-07 · TA获得超过794个赞
知道小有建树答主
回答量:804
采纳率:0%
帮助的人:359万
展开全部
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&checkname
改成
filename=file.filename,不要重命名

但是如果存在重名文件会出问题,需要判断一下,之所以给文件重新命名就是为了避免这个问题
自由标签
2011-04-07 · TA获得超过4923个赞
知道小有建树答主
回答量:2563
采纳率:65%
帮助的人:565万
展开全部
upstreamend.savetofile(server.mappath("../tupian/lbbs_pic/"&filename))'此处pic改成指定目录下文件夹

吧上面这句话里的filename修改成你需要的文件名即可,例如
upstreamend.savetofile(server.mappath("../tupian/lbbs_pic/abc.jpg"))
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友6b4f56c5
2011-04-07 · 超过16用户采纳过TA的回答
知道答主
回答量:77
采纳率:0%
帮助的人:77.7万
展开全部
你把
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)&month(now)&day(now)&hour(now)&minute(now)&second(now)&checkname

这几个取到的是什么,都分别写出来看看,应该就知道如何得到原来的文件名了。
checkname我估计应该是扩展名
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式