62,263
社区成员
发帖
与我相关
我的任务
分享<script type="text/javascript">
function CheckForTestFile(path)
{
var image1 = new Image();
image1.src= path; //改成src
alert(image1.src); //这里路径显示真确
alert(image1.fileSize); //但是这里老是-1 为什么??
if(image1.fileSize > 1024)
{
alert(image1.fileSize+" Bytes文件过大");
}
else
{
alert(image1.fileSize+'可以上传');
}
}
</script>
<input id="file" type="file" />
<input id="Button1" type="button" value="button" onclick="CheckForTestFile(document.getElementById('file').value);" /> <html>
<head>
<title>Test </title>
<SCRIPT>
var imgs=new Image();
imgs.src="44.jpg";
setTimeout("img1.src=imgs.src;",100);
</SCRIPT>
<BODY ONCLICK='alert(imgs.fileSize + "字节")'>
<img id=img1 width=300 height=250>
</BODY>
</html>