<% ''将当前的日期和时间转为流水号
function makefilename(fname)
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,"下午","")
makefilename=fname
end function
%>
上函数体,可使用此句vfname=makefilename(now())来调用当前时间调用,
若response.write vfname则显示:年月日时。
若虚上传时取得所上传的文件的类型,可采用下面这个函数
<%
function GetExtendName(FileName)
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,3)
ExtName = right(ExtName,3-Instr(ExtName,"."))
GetExtendName = ExtName
end function
%>
在用时可以采用这种做法,通过函数instr来完成对上传文件类型的比较
if Instr(".gif.jpg.png",GetExtendName(file.FileName)) then'限制了上传文件类型
'TypeFlag = 1 '文件为允许的类型
vfname = makefilename(now()) '文件为允许的类型执行此行
fname=vfname & "." & GetExtendName(file.FileName)
file.SaveAs Server.mappath(UpFilePath&fname) ''保存文件
else
'TypeFlag = 0 '文件为不允许的类型
response.write ("<script language=javascript>")
response.write ("alert('不支持您所上传的文件类型!');")
response.write ("history.back();")
response.write("</script>")
end if
本文地址:http://com.8s8s.com/it/it7401.htm