Asp.net File Upload Control
<p>I Had a file upload control I want that file will attach only when it is below under some Memory Limit (8 Mb). I get the file size using Ajax and call it on the onchange event. But I am not able to restrict the attachment of files. Can any one Help me ?</p>

<p>This is the example code</p>

<pre><code>function a(obj) {
    if ($(obj).val() != '') {
        var request;
        var flag = false;
        request = $.ajax({
            type: "POST",
            url: 'CheckFileSize.aspx',
            data: "search=" + $(obj).val(),
            success: function (size) {
                if (parseFloat(size) &lt; 8192) {
                    flag = true;
                }
                if (!flag) {
                    alert('File size is greater then 8 MB. The size of the file is ' + (parseFloat(size)) / 1024 + ' MB');
</code></pre>

<p>//Doing something that restrict user from upload enter code here
                        $(obj).val(null);
                    }
                    return flag;
                }
            });
        }
        return false;
    }</p>
