主题:  调试稻香老农的"化境ASP无组件上传类"碰到的问题.

freelyice

职务:普通成员
等级:1
金币:1.0
发贴:159
#12003/7/17 14:15:57
请问我上传图片文件能不能自动重命名?我自己弄来弄去就是弄不成功.比如按上传的时间命名或其他方式等...
非常感谢...



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#22003/7/17 14:19:56
<%OPTION EXPLICIT%>



<%
function getex(filename)
getex = right(filename,(len(filename)-InStr(filename,".")))
End Function

dim upload,file,formName,formPath,fname,getfilename
set upload=new upload_5xSoft ''建立上传对象

if upload.form("filepath")="" then ''得到上传目录
HtmEnd "请输入要上传至的目录!"
set upload=nothing
response.end
else
formPath=upload.form("filepath")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
end if



fname = now()
fname = replace(fname,"-","")
fname = replace(fname," ","")
fname = replace(fname,":","")
fname = replace(fname,"PM","")
fname = replace(fname,"AM","")
fname = replace(fname,"上午","")
fname = replace(fname,"下午","")
fname = fname&Int((right(fname,4) - 0 + 1) * Rnd + 0)

for each formName in upload.file
set file=upload.file(formName)
if file.FileSize>0 then
file.SaveAs Server.mappath(formPath&fname&"."&getex(file.filename))
else
Response.Write "请不要上传0字节文件!返回"
end if
set file=nothing
next
set upload=nothing

%>



freelyice

职务:普通成员
等级:1
金币:1.0
发贴:159
#32003/7/17 14:34:51
搞定,,,
非常感谢,....
非常感谢..........