判断图片大小可以在客户端完成<script>
function GetFileSize()
{
var filename=document.all.File.value;
if(filename=='')
{
return false;
}
try
{
var ado_stream=new ActiveXObject("ADODB.Stream");
//1=adTypeBinary;2=adTypeText
ado_stream.Type=2;
ado_stream.Open();
ado_stream.LoadFromFile(filename);//将文件信息存入流
alert((ado_stream.Size/1024).toFixed(2)+"KB")
}
catch(e)
{
window.confirm(e);
return false;
}
return true;
}
</script>
<input type=file id="File"><input type=button onclick="GetFileSize()">
function GetFileSize()
{
var filename=document.all.File.value;
if(filename=='')
{
return false;
}
try
{
var ado_stream=new ActiveXObject("ADODB.Stream");
//1=adTypeBinary;2=adTypeText
ado_stream.Type=2;
ado_stream.Open();
ado_stream.LoadFromFile(filename);//将文件信息存入流
alert((ado_stream.Size/1024).toFixed(2)+"KB")
}
catch(e)
{
window.confirm(e);
return false;
}
return true;
}
</script>
<input type=file id="File"><input type=button onclick="GetFileSize()">
解决方案 »
- 求高人给指条路
- 求一个实名认证的程序
- Servlet也是一个Java类.为什么我不可以将Serlvet中的变量传递出来
- 关于myeclipse 连接oracle数据库的问题(难)
- 非一般的[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
- 求助:基于SmartClient的java应用实例
- 大家帮我看看这个错误
- 特别奇怪的连接数据库问题 jdk1.4.2 + tomcat4.1+sql server jdbc drive 高分求救!
- 我是初学者,有很多不明白的问题,请高手们指教
- 如何将4字节utf-8的emoji表情转换为unicode字符编码
- 请教各位高手,帮我看看,错误在那,感激地谢谢大家
- HTML页框分割问题
<script>
function UpLoadForm_Validator(pUpLoadForm)
{
if(document.all.UpLoadFile.value=="")
{
window.confirm("请选择上传的文档!");
pUpLoadForm.UpLoadFile.focus();
return false;
}
var strFileFormat=pUpLoadForm.UpLoadFile.value.match(/^(.*)(\.)(.{1,8})$/)[3];//检查上传文件格式
strFileFormat=strFileFormat.toUpperCase();
if(strFileFormat=="DOC"||strFileFormat=="DOT")
{
}
else
{
window.confirm("只能上传.Doc和.Dot,请重新选择!");
return false;
}
return true;
}</script>
<form method="POST" enctype="multipart/form-data" action="" onsubmit="return UpLoadForm_Validator(this)" laguage="JavaScript" name="UpLoadForm">
<input type="file" name="UpLoadFile" id="UpLoadFile" style="visibility:hidden;">
<input type=button onclick="UpLoadFile.click();" style="background-color:#336699">
<input type="submit" value="上传" name="UpLoadButton">
</form>