网学网为需要asp的朋友们搜集整理了通过客户端验证上传图片文件大小的ASP源码相关资料,希望对各位网友有所帮助!
<%@Language=JScript @CodePage=936%>
<Script Language=JScript RunAt=Server>
/****************************************************************\
<lostinet:source xmlns:lostinet="lostinet-d2g-com/source">
<lostinet:source-info>
<lostinet:name>Lostinet_ASP_Upload的例子-动态表单部分</lostinet:name>
<lostinet:description>一个动态的表单的例子</lostinet:description>
</lostinet:source-info>
<lostinet:author-info>
<lostinet:name>Lostinet</lostinet:name>
<lostinet:email>lostinet@21cn.com;lostinet@chongjian.com;</lostinet:email>
<lostinet:homepage>http://lostinet.d2g.com</lostinet:homepage>
</lostinet:author-info>
<lostinet:copyright-info>
<lostinet:copyright>版权声明:这个软件可以随意发布。也可以根据具体情况进行优化修改。但是请保留作者的相关信息。</lostinet:copyright>
</lostinet:copyright-info>
</lostinet:source>
\****************************************************************/
</Script>
<SCRIPT RUNAT=Server LANGUAGE=JScript>
</SCRIPT>
<HTML>
<HEAD>
<TITLE>JScript Example Form</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312" />
</HEAD>
<STYLE>
button
{
border:1px gray solid;
}
div.form_item
{
width:500px;
overflow-x:visible;
padding:4px;
margin-top:8px;
border:2px gray dotted;
}
input.file
{
border:1px gray inset;
width:400px;
}
textarea.info
{
border:1px gray inset;
width:400px;
SCROLLBAR-FACE-COLOR: #cccccc;
SCROLLBAR-HIGHLIGHT-COLOR: WHITE;
SCROLLBAR-SHADOW-COLOR: WHITE;
SCROLLBAR-ARROW-COLOR: maroon;
SCROLLBAR-TRACK-COLOR: #e0e4e4;
SCROLLBAR-3DLIGHT-COLOR: #cccccc;
SCROLLBAR-DARKSHADOW-COLOR: #cccccc;
SCROLLBAR-BASE-COLOR: #cccccc;
}
</STYLE>
<SCRIPT>
var countImgLoading=0;
function GetItemDiv(e)
{
while(e=e.parentElement)
{
if(e.className.toLowerCase()=="form_item")
{
return e;
}
}
throw(new Error(-1,"Impossible:GetItemDiv发生不能处理的意外"));
}
function GetNamedItem(div,name)
{
return div.all(name);
throw(new Error(-11,"Impossible:GetNamedItem发生不能处理的意外"+name));
}
function Check_Item(div)
{
var file=GetNamedItem(div,"file");
var info=GetNamedItem(div,"info");
var width=GetNamedItem(div,"width");
var height=GetNamedItem(div,"height");
var preview=GetNamedItem(div,"preview");
if(file.value.replace(/\s/g,"")=="")
{
file.focus();
return false;
}
if(info.value.replace(/\s/g,"")=="")
{
info.focus();
return false;
}
if(info.value.length>1000)
{
alert("描述的长度不能超过1000字");
info.focus();
return false;
}
if(height.value=="0"||width.value=="0")
{
file.focus();
return false;
}
if(parseInt(height.value)>800||parseInt(width.value)>600)
{
alert("
图片尺寸大于800X600");
file.focus();
return false;
}
if(preview.