快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

澳门新葡新京返水:客户端验证上传文件大小



经由过程客户端验证上传图片文件大年夜小的ASP源码

以下是源代码:

/奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫*\

Lostinet_ASP_Upload的例子-动态表单部分

一个动态的表单的例子

Lostinet

lostinet@21cn.com;lostinet@chongjian.com;

http://lostinet.d2g.com

版权声明:这个软件可以随意宣布。也可以根据详细环境进行优化改动。然则请保留作者的相关信息。

\澳门新葡新京返水奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫*/

JScript Example Form

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;

}

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.src.toLowerCase().indexOf("file://")!=0)

澳门新葡新京返水3;

alert("只能上传本地文件!!\n请把文件框的内容清楚\n然后按浏览");

file.focus();

return false;

}

if(preview.fileSize==0)

{

file.focus();

return false;

}

return preview.fileSize;

}

function Check_Form()

{

if(event==null)var event=new Object();

var totalSize=0;

var haveItem=false;

var coll=form_submit.children;

for(var i=0;i1024*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)

&#澳门新葡新京返水123;

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);

var preview=GetNamedItem(divItem,"preview");

div.style.overflow="hidden";

preview.style.position="static";

}

添加一个必要上传的图片

提交所有内容

要上传图片()的路径:删除

相关的描述:

Add_FormItem();

function btn_add.onclick()

{

Add_FormItem();

}

function btn_submit.onclick()

{

if(Check_Form())

form_submit.submit();

}

您可能还会对下面的文章感兴趣: