<%
Response.Write Request("a")
%>
<form method=post onsubmit="a.value=document.all.x.width + ':' + document.all.x.height">
<input name=a type=hidden>
<input type=file name=f onpropertychange='document.all.x.src=f.value'>
<input type=submit>
<img id=x style="visibility:hidden">
</form>
Response.Write Request("a")
%>
<form method=post onsubmit="a.value=document.all.x.width + ':' + document.all.x.height">
<input name=a type=hidden>
<input type=file name=f onpropertychange='document.all.x.src=f.value'>
<input type=submit>
<img id=x style="visibility:hidden">
</form>
Response.Write Request("a")
%>
<form method=post onsubmit="a.value=document.all.x.width + ':' + document.all.x.height">
<input name=a type=hidden>
<input type=file name=f onpropertychange='document.all.x.src=f.value'>
<input type=submit onclick="document.all.x.width + ':' + document.all.x.height">
<img id=x style="visibility:hidden">
</form>
Response.Write Request("a")
%>
<form method=post onsubmit="a.value=document.all.x.width + ':' + document.all.x.height">
<input name=a type=hidden>
<input type=file name=f onpropertychange='document.all.x.src=f.value'>
<input type=submit onclick="alert(document.all.x.width + ':' + document.all.x.height)">
<img id=x style="visibility:hidden">
</form>
kch = Request.QueryString("kch")
caseno = Request.QueryString("caseno")
lx=Request.QueryString ("lx")
%>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK rel="stylesheet" type="text/css" href="../inc/en.CSS">
<script language="javascript" src="../inc/DateObject.js"></script>
<script language="javascript" src="../inc/main.js"></script>
<title>现场照片</title>
<!--#include file="../INC/bgsub.asp" -->
<script language="javascript">
function CheckData()
{
nLimFileSize=parseInt(document.all.FILE_SIZE.value);
nLimWidth=parseInt(document.all.PICTURE_WIDTH.value);
nLimHeight=parseInt(document.all.PICTURE_HEIGHT.value);
for(i=0;i<document.getElementsByName("Name").length;i++)
{
oName=document.getElementsByName("Name")[i];
oFile=document.getElementsByName("FilePath")[i];
nFileSize=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].fileSize;
nWidth=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].width;
nHeight=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].height;
if(oName.value=="")
{
oName.focus();
alert("名称不能为空!");
return false;
}
if(nFileSize==-1)
{
oFile.focus();
alert("图片为空或类型无效!");
return false;
}
if(nFileSize>nLimFileSize)
{
oFile.focus();
alert("图片文件太大,请限制在" + nLimFileSize + "字节以内!");
return false;
}
if(nWidth>nLimWidth||nHeight>nLimHeight)
{
oFile.focus();
alert("图片太大,请限制在" + nLimWidth + "X" + nLimHeight + "大小!");
return false;
}
}
document.all.img.innerHTML="<div style='position:absolute;border:4px groove pink'><font size=2 color=red>开始保存图片,请耐心等待....</font></div>"
}
function AddMoreRow()
{
oRow=event.srcElement.parentNode.parentNode;
oTable=event.srcElement.parentNode.parentNode.parentNode.parentNode;
oNewRow=oTable.insertRow();
for(i=0;i<oRow.cells.length;i++)
{
oNewRow.insertCell().innerHTML=oRow.cells[i].innerHTML;
}
oRow.all("DelBtn").disabled=false;
oNewRow.all("DelBtn").disabled=false;
oNewRow.className="content";
frames["_hideFrame"]._AddMoreRow();
}
function DeleteThisRow()
{
oRow=event.srcElement.parentNode.parentNode;
oTable=event.srcElement.parentNode.parentNode.parentNode.parentNode;
if(oTable.rows.length>1)
{
frames["_hideFrame"]._DeleteThisRow(oRow.rowIndex);
oTable.deleteRow(oRow.rowIndex);
if(oTable.rows.length==1)
{
oTable.all("DelBtn").disabled=true;
}
}
}
function DisabledKeyInput()
{
if(event.keyCode!=8&&event.keyCode!=46) event.returnValue=false;
}
function HidePreviewPicture()
{
document.all.img.innerHTML="";
}
function VerifyPicture()
{
nLimFileSize=parseInt(document.all.FILE_SIZE.value);
nLimWidth=parseInt(document.all.PICTURE_WIDTH.value);
nLimHeight=parseInt(document.all.PICTURE_HEIGHT.value);
oRow=event.srcElement.parentNode.parentNode;
oImg=frames["_hideFrame"].document.all.VerifyTable.rows[oRow.rowIndex].all.tags("img")[0];
oImg.src=event.srcElement.value;
document.all.img.innerHTML="<img src='" + event.srcElement.value + "'>"
document.all.img.childNodes[0].attachEvent("onerror",HidePreviewPicture)
if(oImg.readyState=="complete")
{
if(oImg.fileSize==-1)
{
alert("文件类型无效!")
}
else if(oImg.fileSize>nLimFileSize)
{
alert("图片文件太大,请限制在" + nLimFileSize + "字节以内!")
}
else if(oImg.width>nLimWidth||oImg.height>nLimHeight)
{
alert("图片太大,请限制在" + nLimWidth + "X" + nLimHeight + "大小!")
}
}
}
</script>
</HEAD>
<body <%=rightkey%> class=scrollbar1 topmargin=10>
<form target="_hideFrame" method=post enctype="multipart/form-data" action="BatchAddPicture_DB.asp?kch=<%=kch%>&caseno=<%=caseno%>&lx=<%=lx%>" onsubmit="return CheckData()">
<table>
<tr>
<td>
<a href="xckcpiclisttp.asp?kch=<%=kch%>&caseno=<%=caseno%>&lx=<%=lx%>" id=BackLink><img SRC="../../images/back.gif" BORDER="0" WIDTH="48" HEIGHT="19"></a>
</td>
</tr>
</table>
<%call bghead()%>
<table><th><%=lx%>批量上传</th></table>
<%call bgmid()%>
<table style="color:<%=session("color")%>;font-size:<%=session("size")%>">
<tr class=content>
<td nowrap>名称*</td>
<td><input type="text" name="Name" size=15 maxlength="50"></td>
<td nowrap>文件路径*</td>
<td>
<input type=file name="FilePath" size=15 onkeydown="DisabledKeyInput()" onpropertychange="VerifyPicture()">
</td>
<td nowrap>说明</td><td><input type=text name=Description size=45><input type="button" class="input1" value="增加" onclick="AddMoreRow()"></td>
<td nowrap> <input type="button" class="input1" id=DelBtn value="删除" disabled onclick="DeleteThisRow()"></td>
</tr>
</table>
<table style="color:<%=session("color")%>;font-size:<%=session("size")%>">
<tr align =center>
<td class="tijiao" align =center>
<input type="submit" class="input1" value="保存" id=submit1 name=submit1> <input type="reset" class="input1" value="取消" id=reset1 name=reset1>
</td>
</tr>
</table>
<iframe src="about:blank" width=100% height=0 name="_hideFrame"></iframe>
<%caLL bgbottom()%>
<div id="img"></div>
<div id=tempHTML style="display:none">
<script>
function _AddMoreRow()
{
oCell=document.all.VerifyTable.insertRow().insertCell();
oImg=document.createElement("img");
oImg.attachEvent("onreadystatechange",_VerifyPicture);
oImg.attachEvent("onerror",_PictureError);
oCell.appendChild(oImg);
}
function _DeleteThisRow(rowIndex)
{
document.all.VerifyTable.deleteRow(rowIndex);
}
function _PictureError()
{
if(event.srcElement.fileSize==-1)
{
alert("无效的图片类型!");
}
}
function _VerifyPicture()
{
oImg=event.srcElement;
if(oImg.readyState=="complete")
{
nWidth=parseInt(parent.document.all.PICTURE_WIDTH.value);
nHeight=parseInt(parent.document.all.PICTURE_HEIGHT.value);
nFileSize=parseInt(parent.document.all.FILE_SIZE.value);
if(oImg.width>nWidth||oImg.height>nHeight)
{
alert("图片尺寸太大,请限制在" + nWidth + "X" + nHeight + "大小!")
}
else if(oImg.fileSize>nFileSize)
{
alert("图片文件超出限定大小,请限定在" + nHeight + "字节以内!")
}
}
}
</script>
<table border=0 id=VerifyTable>
<tr><td><img border=0 onerror="_PictureError()" onreadystatechange="_VerifyPicture()"></td></tr>
</table>
</div>
<script language=javascript>
function InitFrame()
{
frames["_hideFrame"].document.write(document.all.tempHTML.innerHTML);
}
window.onload=InitFrame;
</script>
</form>
</BODY>
</HTML>
<!--#include file="../inc/foot.inc"-->
<!--#include file="../inc/title.asp"-->
可是问题还是没有解决,我想知道为什么我的循环检测的方法不行。还有,在浏览文件的同时进行检测是可以,但是如果不合规定怎么把那个文件域里的东西清空呢?文件域的value是只读的。请教高手。谢谢