日期:2014-05-17  浏览次数:21086 次

无组件上传自动生成文件问题
代码如下问题很简单 就是想实现 如 ../../picdb/mp3/2010/ 目录

可以上传后自动生成如 ../../picdb/mp3/2010-2-27/

小弟先向各位大哥表示感谢了

f upload.err > 0 then
  select case upload.err
case 1
Response.Write "<table><tr><td bgcolor=#ffffff>请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</td></tr></table>"
case 2
Response.Write "<table><tr><td bgcolor=#ffffff>文件大小超过了限制 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</td></tr></table>"
end select
exit sub
else
formPath="../../picdb/mp3/2010/"'upload.form("filepath")
'在目录后加(/)
'if right(formPath,1)<>"/" then formPath=formPath&"/"

for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象

fileExt=lcase(file.FileExt)

'判断文件类型
if lcase(fileEXT)="asp" and lcase(fileEXT)="asa" and lcase(fileEXT)="aspx" then
CheckFileExt(fileEXT)=false
end if
if CheckFileExt(fileEXT)=false then
  response.write "<table><tr><td bgcolor=#ffffff>文件格式不正确 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</td></tr></table>"
response.end
end if

'付值变量
randomize
ranNum=int(90000*rnd)+10000
file_name=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
filename=file_name&"."&fileExt
rename=filename&"|"
filename1=formPath&filename
Filesize=file.FileSize

'记录文件
if Filesize>0 then '如果 FileSize > 0 说明有文件数据
file.SaveToFile Server.mappath(FileName1) ''执行上传文件
'call ImgWriter(FileName1)'添加水印
call checksave() '记录文件
end if
set file=nothing
next
end if
set upload=nothing
response.write "<table><tr><td bgcolor=#ffffff>2010/"&FileName&"上传成功![ <a href=# onclick=history.go(-1)>重新上传</a> ]</td></tr></table>"
end sub

'判断文件类型是否合格
Private Function CheckFileExt (fileEXT)
dim Forumupload
Forumupload=split("jpg|gif|png|wma","|")
for i=0 to ubound(Forumupload)
if lcase(fileEXT)=lcase(trim(Forumupload(i))) then
CheckFileExt=true
exit Function
else
CheckFileExt=false
end if
next
End Function

Private sub checksave()
'插入上传表并获得ID
response.write "<script>parent.form2.pic.value='/mp3/2010/"&FileName&"'</script>"
end Sub
Sub ImgWriter(SaveImgPath) '添加水印
dim jpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open Server.MapPath(SaveImgPath)
Jpeg.Canvas.Font.Color = &Hffffff
Jpeg.Canvas.Font.Family = "Tahoma"
Jpeg.Canvas.Font.Size = 16
Jpeg.Canvas.Font.ShadowColor = &H000000
Jpeg.Canvas.Font.ShadowXoffset = -1
Jpeg.Canvas.Font.ShadowYoffset = 1
Jpeg.Canvas.Font.Bold = true
Jpeg.Canvas.Print 10, 10, "Maxz.cn"
Jpeg.Canvas.Pen.Color = &Heeeeee
Jpeg.Canvas.Pen.Width = 1
Jpeg.Canvas.Brush.Solid = False
Jpeg.Canvas.Bar 0, 0, Jpeg.Width, Jpeg.Height
Jpeg.Save Server.MapPath(SaveImgPath)
End Sub
%>




------解决方案--------------------
file_name=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum 


改为

file_name=year(now)&