本页内容是《客户端控制上传图像大小》同时我们还提供济宁地区的网站建设,百度,雅虎,google的推广,点金,商友,等营销软件
请输入关键字:

标题搜索 内容搜索  

你现在所在的位置->首页->javascript->客户端控制上传图像大小

客户端控制上传图像大小

时间:[2007-10-9 15:51:27]     作者:作者不详

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>客户端控制上传图像大小示例 - 51windows</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<p>以下是一个客户端控制file上传图像大小的一个示例,由于是客户端限制,所以用户可以绕过这个限制。</p>
<SCRIPT LANGUAGE="JavaScript">
<!--
var FileMaxSize = 50;//限制上传的文件大小,单位(k)
function chkform(){
 if (document.HwForm.Photo.value==""){alert("请选择照片");document.HwForm.Photo.focus();return false;}
 if(document.HwForm.PhotoFileSize.value<=0){alert("请重新选择照片");document.HwForm.Photo.focus();return false;}
 if(document.HwForm.PhotoFileSize.value>FileMaxSize*1024){alert("选择的照片超过"+FileMaxSize+"K,请重新选择");document.HwForm.Photo.focus();return false;}
 alert("可以提交,当前为测试...");return false;
}
//-->
</SCRIPT>
<form method="POST" name="HwForm" onsubmit="return(chkform());" enctype="multipart/form-data">
照片(请选择一个50K以内的图片文件):<input type="file" name="Photo" onpropertychange="if(document.HwForm.Photo.value!=''){document.getElementById('PhotoImg').src=document.HwForm.Photo.value;}"/><IMG style="POSITION: absolute; TOP: -100000px;left:-100000px;" onerror="document.all.PhotoFileSize.value='-1';alert('请选择一个图像文件');" onload="if(document.getElementById('PhotoImg').fileSize<=1024*FileMaxSize){document.all.PhotoFileSize.value=document.getElementById('PhotoImg').fileSize;}else{alert('图片不能大于'+FileMaxSize+'K,请重新选择');document.all.PhotoFileSize.value='-1';}" id="PhotoImg"><input size="3" type="hidden" name="PhotoFileSize" value="-1" />
<input type="submit" value="提交"> <input type="reset" value="重置">
</form>
</body>
</html>

【声明】本站刊载的《客户端控制上传图像大小》一文如果有侵害你权益的情况,请联系我们。我们将及时采取措施。
QQ:44637339 Email:just6@163.com Tel:13355163107 Lining studios

友情链接

本页内容是《客户端控制上传图像大小》 返回顶部
© 2001-2024 Lining studios 济宁速创科技有限公司, All Rights Reserved
 Processed Time:46.875ms
中华人民共和国信息产业部网站备案号: 鲁ICP备09103015号-1