Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

i have a asp:fileupload for uploading files.
But i need some javascript or can use custom validator to show the content length of fileupload can not exceed a limit.
Posted
Comments
hitech_s 30-Aug-11 5:30am    
file upload is for images or documents..?

 
Share this answer
 
Comments
@nuraGGupta@ 30-Aug-11 5:35am    
Good links. Take 5.
RaisKazi 30-Aug-11 5:37am    
Thank you.
leonidasvijay 30-Aug-11 5:49am    
can this happen on client side.
like we r using custom validator. and we can use client validation function.
hav any suggestion
C#
<asp:fileupload id="FileUpload1" runat="server" xmlns:asp="#unknown" />

Put a div behind
HTML

to hold the error message
XML
<div id="spnErrorLogo" runat="server">
                                            </div>


Now add the following code at code behind
C#
Int64 intFileSize = Convert.ToInt64(FileUpload1.PostedFile.ContentLength);
                if (intFileSize > 3145728)
                {
                    spnErrorLogo.InnerHtml = "Maximum file size exceeded.
 Please upload a file less than 3 MB in size.";
}
 
Share this answer
 
If you are uploading larger type file
in Web.config
XML
<system.web>

<httpruntime>
executionTimeout="90" 
maxRequestLength="4096" 
useFullyQualifiedRedirectUrl="false" 
minFreeThreads="8" 
minLocalRequestFreeThreads="4" 
appRequestQueueLimit="100" 
enableVersionHeader="true"
/>
    </system.web></httpruntime>


change the value to some other value of your choice (8192 for 8 Mb, 16384 for 16 Mb, 65536 for 64 Mb.
may help
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900