<%@ Page
Language="C#"
AutoEventWireup="true"
CodeFile="fileupload_size.aspx.cs"
Inherits="fileupload_size"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript"
src="
http://code.jquery.com/jquery-1.7.1.js"></script>
<script type="text/javascript">
$(function () {
$('#btn_upload').click(function () {
var f = $('#fileupload1')[0].files[0];
var size = (f.size / 1024 /
1024).toFixed(2); //convert size byte to mb
if (f.size > 15728640) {
alert("Your File Size is " +
size + "MB, Maximum Allow is 15MB");
return false;
}
else {
return true;
}
})
})
</script>
</head>
<body>
<form id="form1" runat="server">
<center>
<br />
<br />
<div>
<table>
<tr>
<td>
Upload file
</td>
<td>
<asp:FileUpload ID="fileupload1"
runat="server"
/>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btn_upload"
runat="server"
Text="Upload"
/>
</td>
</tr>
</table>
</div>
</center>
</form>
</body>
</html>
No comments:
Post a Comment