views:

22

answers:

0

i am using a file upload control. user can upload any files less than 5 mb. but fileupload controls goes to erropage if someone tried to upload larger files. after search in net about it i found that there is setting in web.config file. first i set maximum request length to 5MB. but if someone try to upload a larger file (> 5MB) it goes to error page. So i set maximum requset length to be a maximum value. that is shown below

 <httpRuntime executionTimeout="999999" maxRequestLength="2097151" useFullyQualifiedRedirectUrl="false" requestLengthDiskThreshold="18192"/>

the code behind is shown below

if (fuDocument.HasFile)
            { 
  if (fileSize <= 5242880)
                {
                    // code to uplad the file
                }
               else
                {
                     //commonop is a custom class . i can display alerts using show  alert function.
         CommonOp.ShowAlert("This file exceeds the 5MB attachment limit. Sorry.", Page);
        return;
                 }

           }

now i have very strange problem. My program works fine on my machine . it shows my alert message if file is greater than 5MB.

after uploading to server it not working fine . it does not give error( so i am happy for that) . but if some one try to upload a file having larger size , sometimes its showing my alert message. bust sometime it does not shows the alert message. i cant predict when it show my alert message. its just refreshing to the same page. Why it do not show alert message every time when user try to upload a file having size larger than 5 MB

I also want to know about Is there anyway to check file size on client side??