| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1276 人关注过本帖
标题:我想要判断图片大与1M的时候就结束跳回去
只看楼主 加入收藏
rtc
Rank: 2
等 级:新手上路
威 望:4
帖 子:590
专家分:0
注 册:2007-6-6
收藏
 问题点数:0 回复次数:17 
我想要判断图片大与1M的时候就结束跳回去

<%
'----------------------------------------------------------
'***************** 风声无组件上传类 2.0 *****************
'用法举例:快速应用[添加产品一]
'该例主要说明默认模式下的运用
'以常见的产品更新为例
'下面是上传程序(upload.asp)的代码和注释
'**********************************************************
'----------------------------------------------------------
OPTION EXPLICIT
Server.ScriptTimeOut=999
%>
<!--#include FILE="UpLoadClass.asp"-->
<!--#include file="inc\conn1.asp"-->

<%
dim lm
lm = request.QueryString("lm")
if isnumeric(lm) then
lm =cint(lm)
else
lm = 0
end if

if lm < 1 or lm > 2 then
response.Write("非法栏目号或该栏目不存在!")
response.end()
end if %>

<%
dim request2

'建立上传对象
Set request2=new UpLoadClass
request2.MaxSize = 5000*1024
request2.FileType = "gif/jpg"
request2.Savepath = "SCPIC/"
request2.open
%>
<%
if request2.form("title")="" then
response.Write("<script language='javascript'>alert('标题不能为空,请输入标题');this.top.location.href='admin.asp';</script>")
response.end()
end if
if request2.form("word")="" then
response.Write("<script language='javascript'>alert('内容不能为空,请输入内容');this.top.location.href='admin.asp';</script>")
response.end()
end if

%>

<html>
<head>
<title>发表成功</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../style/basic.css" rel="stylesheet" type="text/css">
<link href="admin.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="760" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF" class="xmenu" style="border:1px solid #999999">
<tr>
<td>
<blockquote>
<%

'显示类版本
response.Write("<br>"&request2.version&"<br>")

'显示产品名称
response.Write("<br>标题:"&request2.Form("title"))

'显示源文件路径与名称
response.Write("<br>附件地址:"&request2.Form("strPhoto_Path")&request2.Form("strPhoto_Name"))
response.Write("=>")

'显示目标文件路径与名称
response.Write(request2.SavePath&request2.Form("strPhoto"))

'显示产品介绍
response.Write("<br>作者:"&request2.Form("zuozhe"))

response.Write("<br>内容:"&request2.Form("word"))

'-------说明开始------
'可以看出上面的显示是淋漓尽致的
'文件是否需要保存由类自动判断,这已经符合大多数情况下的应用
'如果您需要更灵活的处理,参见[进阶应用]
'-------说明结束------

%>
</blockquote></td>
</tr>
</table>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<table width="550" border="0" align="center" cellpadding="0" cellspacing="0" class="addwen">
<tr>
<td align="center">Copyright @ Rt-word@2007 All rights reserved</td>
</tr>
</table>
</body>
</html>

<%
dim rs,sql,cn
set rs=server.CreateObject("adodb.recordset")
sql="select*from word "
rs.open sql,cn,1,3
rs.addnew
rs("lmid")=lm
rs("classid")=request2.Form("classid")
rs("title")=request2.Form("title")
rs("word")=request2.Form("word")
rs("zuozhe")=request2.Form("zuozhe")
rs("date")=now()
if request2.Form("strPhoto")<>"" then
rs("picdz")=request2.Form("strPhoto")
rs("pictitle")=request2.Form("strPhoto_Name")
end if


rs.update
%>
<%
'释放上传对象
set request2=nothing
%>

我想要判断图片大与1M的时候就结束跳回去
如果上传的类型不是jpg和 gif话就结束跳回去

该如何做那个高手指教

搜索更多相关主题的帖子: 风声 判断 结束 OPTION 
2007-07-08 17:18
rtc
Rank: 2
等 级:新手上路
威 望:4
帖 子:590
专家分:0
注 册:2007-6-6
收藏
得分:0 
?????????
2007-07-08 20:46
ASP汽车
Rank: 1
等 级:新手上路
帖 子:197
专家分:0
注 册:2007-7-4
收藏
得分:0 

dim filename,fileExt,filesizemin,filesizemax

filesizemin=10
filesizemax=1000*1024
'********************************检测文件大小***************************************************
If file.filesize<filesizemin Then
response.write "你上传的文件太小了 [ <a href=# onclick=history.go(-1)>请重新上传</a> ]&nbsp;&nbsp;&nbsp;&nbsp;"
response.end
ElseIf file.filesize>filesizemax then
response.write "文件大小超过了 "&filesizemax&"字节 限制[ <a href=# onclick=history.go(-1)>请重新上传</a> ]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
response.end
End If
'********************************检测文件类型****************************************************
fileExt=ucase(right(file.filename,4))
uploadsuc=false
Forum_upload="JPG|GIF"
Forumupload=split(Forum_upload,"|")
for i=0 to ubound(Forumupload)
if fileEXT="."&trim(Forumupload(i)) then
uploadsuc=true
exit for
else
uploadsuc=false
end if
next
if uploadsuc=false then
response.write "文件格式不正确 [ <a href=# onclick=history.go(-1)>请重新上传</a>]&nbsp;&nbsp;&nbsp;&nbsp;"
response.end
end if

发给你,你自己参照着改就可以了


学习ASP中.....难啊......
2007-07-09 08:44
rtc
Rank: 2
等 级:新手上路
威 望:4
帖 子:590
专家分:0
注 册:2007-6-6
收藏
得分:0 
谢谢你 开心!!
先试试
2007-07-09 09:39
rtc
Rank: 2
等 级:新手上路
威 望:4
帖 子:590
专家分:0
注 册:2007-6-6
收藏
得分:0 

<%
dim request2,minsize

'建立上传对象
Set request2=new UpLoadClass
request2.minsize=10
request2.MaxSize = 1*1024
request2.FileType = "gif/jpg"
request2.Savepath = "SCPIC/"
request2.open
%>
<%
if request2.form("title")="" then
response.Write("<script language='javascript'>alert('标题不能为空,请输入标题');this.top.location.href='admin.asp';</script>")
response.end()
end if
if request2.form("word")="" then
response.Write("<script language='javascript'>alert('内容不能为空,请输入内容');this.top.location.href='admin.asp';</script>")
response.end()
end if

'********************************检测文件大小***************************************************
If request2.Form("strphoto_Size")<request2.minsize Then
response.write "你上传的文件太小了 [ <a href=# onclick=history.go(-1)>请重新上传</a> ]&nbsp;&nbsp;&nbsp;&nbsp;"
response.end
ElseIf request2.Form("strphoto_Size")>request2.MaxSize then
response.write "文件大小超过了 "
response.End()
End If
%>


还是不行吖

2007-07-09 09:47
rtc
Rank: 2
等 级:新手上路
威 望:4
帖 子:590
专家分:0
注 册:2007-6-6
收藏
得分:0 
'********************************检测文件类型****************************************************
fileExt=ucase(right(file.filename,4))
uploadsuc=false
Forum_upload="JPG|GIF"
Forumupload=split(Forum_upload,"|")
for i=0 to ubound(Forumupload)
if fileEXT="."&trim(Forumupload(i)) then
uploadsuc=true
exit for
else
uploadsuc=false
end if
next
if uploadsuc=false then
response.write "文件格式不正确 [ <a href=# onclick=history.go(-1)>请重新上传</a>]&nbsp;&nbsp;&nbsp;&nbsp;"
response.end
end if

这个能介绍下吗
不介绍根本改不了
2007-07-09 09:50
ASP汽车
Rank: 1
等 级:新手上路
帖 子:197
专家分:0
注 册:2007-7-4
收藏
得分:0 
以下是引用rtc在2007-7-9 9:50:43的发言:
'********************************检测文件类型****************************************************
fileExt=ucase(right(file.filename,4))
uploadsuc=false
Forum_upload="JPG|GIF"
Forumupload=split(Forum_upload,"|")
for i=0 to ubound(Forumupload)
if fileEXT="."&trim(Forumupload(i)) then
uploadsuc=true
exit for
else
uploadsuc=false
end if
next
if uploadsuc=false then
response.write "文件格式不正确 [ <a href=# onclick=history.go(-1)>请重新上传</a>]&nbsp;&nbsp;&nbsp;&nbsp;"
response.end
end if

这个能介绍下吗
不介绍根本改不了

这个是不用改的,这段程序的功能就是检测文件名的后缀是什么类型的,如果是 Forum_upload="JPG|GIF",就上传,如果不是格式就不对,重新上传


学习ASP中.....难啊......
2007-07-09 10:35
rtc
Rank: 2
等 级:新手上路
威 望:4
帖 子:590
专家分:0
注 册:2007-6-6
收藏
得分:0 
问题 是我加了之后没反应吖.!!!!!!!
2007-07-09 11:30
放任一切
Rank: 2
等 级:新手上路
威 望:4
帖 子:217
专家分:0
注 册:2007-3-22
收藏
得分:0 
http://bbs.bc-cn.net/viewthread.php?tid=152552
看看这个贴子对你有没有帮助
2007-07-09 11:35
rtc
Rank: 2
等 级:新手上路
威 望:4
帖 子:590
专家分:0
注 册:2007-6-6
收藏
得分:0 

ASP汽车,伱的代码出现的错误!!!!!!!!!!!

Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

Microsoft VBScript 运行时错误 错误 '800a01f4'

变量未定义: 'file'

/upload.asp,行46

2007-07-09 11:39
快速回复:我想要判断图片大与1M的时候就结束跳回去
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017929 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved