求用asp编写的文件上传程序,路径存在数据库,文件在服务器端文件夹下

2025-04-10 14:17:17
推荐回答(1个)
回答1:

请高手帮忙看下到底哪错了,有些文件上传不了
<%
Call CheckUserLogin(username)
Dim upload,filepath,filelx,formName,EditName,wjname,userfaceid
Dim upfilename,filename,todb_filename,fileExt,i,filen,ranNum
Dim MaxUpSize
set upload=new upload_file
if upload.form("act")="uploadfile" then
filepath=upload.form("filepath")
filelx=upload.form("filelx")
formName=upload.form("formName") '回传到上页面编辑框所在Form的Name
EditName=upload.form("EditName") '回传到上页面编辑框的Name
wjname=upload.form("wjname")
userfaceid=upload.form("userfaceid")

MaxUpSize=UpImgSize
if filelx="swf" then MaxUpSize=UpFlashSize
if filelx="wmp" then MaxUpSize=UpWMPSize
if filelx="real" then MaxUpSize=UpRealSize
if userfaceid<>"" then MaxUpSize=GetCnkConfig(45)

i=0
for each upfilename in upload.File
set filen=upload.File(upfilename)
fileExt=lcase(filen.FileExt) '得到的文件扩展名不含有.
if filen.filesize<100 then Call alertmsg("请先选择你要上传的文件!")
if (filelx<>"jpg") then Call alertmsg("该文件类型不能上传!")
if filelx="jpg" then
if fileext<>"gif" and fileext<>"jpg" and fileext<>"png" then Call alertmsg("只能上传.jpg或.gif或.png格式文件!")
end if
if filelx="swf" then
if fileext<>"swf" then Call alertmsg("只能上传.jpg或.gif或.png格式文件!")
end if
if filelx="wmp" then
if fileext<>"wma" and fileext<>"wmv" and fileext<>"mp3" then Call alertmsg("只能上传.wma或.wmv或.mp3格式文件!")
end if
if filelx="real" then
if fileext<>"rm" and fileext<>"ram" and fileext<>"rmvb" then Call alertmsg("只能上传.rm或.ram或.rmvb格式文件!")
end if
if filen.filesize>(MaxUpSize*1024) then Call alertmsg("最大只能上传 "&MaxUpSize&"K 的文件!")
if wjname="" then
randomize
ranNum=int(90000*rnd)+10000
filename=filepath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt '程序写入的完整的路径及文件名
todb_filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt '写入数据库的文件名
else
filename=filepath&wjname&userfaceid&"."&fileExt '程序写入的完整的路径及文件名(user+用户id)
todb_filename=wjname&userfaceid&"."&fileExt '写入数据库的文件名
end if
if filen.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
filen.SaveToFile Server.mappath(filename) '保存文件
Call ChkHackWord(filename)
if userfaceid="" then
Call CnkRocordTodayNum(12,"UpLoadNum")
response.write ""
else
conn.execute("update cnk_users set userface='"&todb_filename&"' where UserID="&userfaceid)
response.write "" '回到原打开的窗口
end if
end if
set filen=nothing
next
set upload=nothing
end if
Call closedb()
%>

'以上某部分代码修改:
if (filelx<>"jpg" and filelx<>"gif" and filelx<>"bmp" )