看看上传哪里错啊?
<!--#include file="uplaod_class.asp"--><!--#include file="../inc/conn.asp"-->
<%
Const EnableUploadFile="Yes" '是否开放文件上传
Const MaxFileSize=4028 '上传文件大小限制 单位k
Const SaveUpFilesPath="UploadFiles" '存放上传文件的目录
Const UpFileType="avi|rm|wav|wma|midi|mp3" '允许的上传文件类型
dim upload,oFile,formName,SavePath,filename,fileExt
dim ImgWidth,ImgHeight
dim EnableUpload
dim arrUpFileType
dim ranNum
dim msg,FoundErr
msg=""
FoundErr=false
EnableUpload=false
SavePath = SaveUpFilesPath '存放上传文件的目录
if right(SavePath,1)<>"/" then SavePath=SavePath&"/" '在目录后加(/)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<%
if EnableUploadFile="No" then
response.write "系统未开放文件上传功能"
else
call upload_0() '使用无组件上传类
end if
%>
</body>
</html>
<%
sub upload_0() '使用无组件上传类
set upload=new uplaod_class '建立上传对象
upload.GetData(10240) '取得上传数据,限制最大上传10M
if upload.err > 0 then '如果出错
select case upload.err
case 1
response.write "请先选择你要上传的文件!"
case 2
response.write "你上传的文件总大小超出了最大限制(10M)"
end select
response.end
end if
ImgWidth=trim(upload.form("ImgWidth"))
ImgHeight=trim(upload.form("ImgHeight"))
if ImgWidth="" then
ImgWidth=0
else
ImgWidth=Clng(ImgWidth)
end if
if ImgHeight="" then
ImgHeight=0
else
ImgHeight=Clng(ImgHeight)
end if
for each formName in upload.file '列出所有上传了的文件
set ofile=upload.file(formName) '生成一个文件对象
if ofile.filesize<100 then
msg="请先选择你要上传的文件!"
FoundErr=True
end if
if ofile.filesize>(MaxFileSize*1024) then
msg="文件大小超过了限制,最大只能上传" & CStr(MaxFileSize) & "K的文件!"
FoundErr=true
end if
fileExt=lcase(ofile.FileExt)
arrUpFileType=split(UpFileType,"|")
for i=0 to ubound(arrUpFileType)
if fileEXT=trim(arrUpFileType(i)) then
EnableUpload=true
exit for
end if
next
if fileEXT="asp" or fileEXT="asa" or fileEXT="aspx" then
EnableUpload=false
end if
if EnableUpload=false then
msg="这种文件类型不允许上传!\n\n只允许上传这几种文件类型:" & UpFileType
FoundErr=true
end if
sql="select * from ad_user_music"
Set rs= Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,3,3
strJS="<SCRIPT language=javascript>" & vbcrlf
if FoundErr<>true then
randomize
ranNum=int(900*rnd)+100
filename=SavePath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
rs.addnew
rs("ad_user_mn")=filename
rs("ad_user_fake")=0
rs("ad_user_dtime")=now()
rs.update
ofile.SaveToFile Server.mappath(FileName) '保存文件
msg="上传文件成功!"
end if
strJS=strJS & "alert('" & msg & "');" & vbcrlf
strJS=strJS & "history.go(-1);" & vbcrlf
strJS=strJS & "</script>"
response.write strJS
set file=nothing
next
set upload=nothing
end sub
%>
<script language=javascript>
alert('上传图片成功!')
window.location.href("upload.asp")
</script>