<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>上傳</title>
<script language="JavaScript">
<!--
function checkFile(sizeLimit)
{
var me = document.all;
var img = new Image();
document.MM_returnValue = false;
img.sizeLimit = sizeLimit;
img.src = 'file:///' + me.File1.value;
alert(img.fileSize);
//img.onload = showImageDimensions;
}
function showImageDimensions()
{
if (this.fileSize > this.sizeLimit)
{
alert('您所選擇的檔案大小為 '+ (this.fileSize/1000) +' kb,\n超過了上傳上限 ' + (this.sizeLimit/1000) + ' kb!\n不允許您上傳喔!');
return;
}
document.MM_returnValue = true;
alert(document.MM_returnValue);
}
//-->
</script>
</head>
<body oncontextmenu="window.event.returnValue=false">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center">
圖片: <input type="file" name="File1">
<input type="submit" name="btn1" value="確定上傳" onclick="checkFile(100000);return document.MM_returnValue;">
</div>
</td>
</tr>
</table>
</body>
</html>
來源引自 : http://www.pro-soho.com/Blog/article.asp?id=83
沒有留言:
張貼留言