asp上传的文件大小超出限制,没提示“文件超出限制”,提示的是“产品名称不能为空”的提示框!!!
dim upload,file,formName,formPath,iCount,filename,fileExt,title
set upload=new upload_5xSoft ''建立上传对象
title=upload.form("title")
formPath=upload.form("ipath")
''在目录后加(/)
shuoming=upload.form("shuoming")
sclass=upload.form("sclass")
if right(formPath,1)<>"/" then formPath=formPath&"/"
if trim(title)="" then
response.Write("<script>alert(""产品名称不能为空"");history.back();</script>")
response.End()
end if
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.filesize<100 then
response.Write ("<script>alert(""请选择要上传的文件!!"");history.back();</script>")
response.end
end if
if file.filesize>1024000 then
response.Write ("<script>alert(""文件大小超出了限制,请重新上传!!"");history.back();</script>")
response.end
end if
fileExt=lcase(right(file.filename,4))
if fileEXT<>".jpg" and fileEXT<>".gif" and fileEXT<>".bmp" and fileEXT<>".png" and fileEXT<>".swf" then
response.Write ("<script>alert(""文件格式不正确,请重新上传!!"");history.back();</script>")
response.end
end if
------解决方案--------------------
先后判断的问题. 你把:
if file.filesize>1024000 then
response.Write ("<script>alert(""文件大小超出了限制,请重新上传!!"");history.back();</script>")
response.end
end if
放到 产品名称判断的前面