RE: get image side via client side script before file uplaod
From: Steven Cheng[MSFT] (v-schang_at_online.microsoft.com)
Date: 07/16/04
- Next message: Tampa .NET Koder: "RE: ADO.NET via Javascript"
- Previous message: Billy Horne: "Re: WebForms and timeouts / loss of session data"
- In reply to: moondaddy: "get image side via client side script before file uplaod"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 16 Jul 2004 04:50:32 GMT
Hi Moondaddy,
AS for image 's "fileSize" return -1 problem, I suspect that whether it is
caused by the image object is not completely loaded. Based on my research
,the image object contains a member property called "complete" which
indicate whether the image has been completely loaded or not. So I think we
can put a "If..." statement before we get the image's fileSize for example
if(im.complete== true)
{
alert(im.fileSize);
}
And here is a test page I've made and you can also have a test on your side
to see whether it works.
=================aspx page====================
<HTML>
<HEAD>
<title>CheckImageSize</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
var im;
function loadImage()
{
im = new Image();
im.src = document.getElementById("imgUploader").value;
}
function checkSize()
{
if(im!=null && im.complete == true)
{
alert(im.fileSize);
}
else
{
alert("not completely loaded!");
}
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td>
<INPUT id="imgUploader" type="file" onpropertychange="loadImage()">
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>
<INPUT type="button" value="Check Image File Size"
onclick="checkSize()">
</td>
</tr>
</table>
</form>
</body>
</HTML>
=========================
Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
- Next message: Tampa .NET Koder: "RE: ADO.NET via Javascript"
- Previous message: Billy Horne: "Re: WebForms and timeouts / loss of session data"
- In reply to: moondaddy: "get image side via client side script before file uplaod"
- Messages sorted by: [ date ] [ thread ]