通过客户端验证上传图片文件大小的ASP源码(3)
}
if(haveItem==false)
{
Add_FormItem();
return event.returnValue=false;
}
if(totalSize==0)
{
alert("不打算上传了");//暂时没有可能执行
return event.returnValue=false;
}
if(totalSize>1024*1024)
{
alert("不能上传超过1M的数据");
return event.returnValue=false;
}
btn_submit.disabled=true;
return event.returnValue=true;
}
function Add_FormItem()
{
form_submit.elements("input_submit").insertAdjacentHTML("beforebegin",form_template.innerHTML);
}
function Delete_FormItem()
{
var btn=event.srcElement;
GetItemDiv(btn).removeNode(true);
}
function Show_Preview()
{
var div=GetItemDiv(event.srcElement);
var preview=GetNamedItem(div,"preview");
var file=GetNamedItem(div,"file");
if(preview.readyState=="uninitialized"||preview.readyState=="complate")countImgLoading++;
btn_submit.disabled=true;
preview.src=file.value;
}
function OnPreviewLoad(secceed)
{
btn_submit.disabled=false;//bug:当表单在提交的时候,忽略
countImgLoading--;
var div=GetItemDiv(event.srcElement);
var preview=GetNamedItem(div,"preview");
var height=GetNamedItem(div,"height");
var width=GetNamedItem(div,"width");
if(secceed)
{
height.value=preview.height;
width.value=preview.width;
}
else
{
height.value=width.value="0";
}
var filesize=GetNamedItem(div,"filesize");
filesize.innerText=Math.floor(preview.fileSize/1024)+"K";
}
function OnPreviewMouseOver(div)
{
if(div.contains(event.fromElement))return;
var divItem=GetItemDiv(div);
var preview=GetNamedItem(divItem,"preview");
div.style.overflow="visible";
preview.style.position="absolute";
}
function OnPreviewMouseOut(div)
{
if(div.contains(event.toElement))return;
var divItem=GetItemDiv(div);
var preview=GetNamedItem(divItem,"preview");
div.style.overflow="hidden";
preview.style.position="static";
}
function OnPreviewClick(div)
{
var divItem=GetItemDiv(event.srcElement);
内容版权声明:除非注明,否则皆为本站原创文章。