Maximum filesize

Thread is closed for posting
6 posts, 0 answers
  1. Dick
    Dick avatar
    36 posts
    Member since:
    Sep 2007

    Posted 19 Sep 2011 Link to this post

    We want to limit the upload filesize. We created a test project using samples on the telerikwebsite. When maximum filesize is reached an error is thrown. What am i doing wrong? Below the code:


    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
    <script type="text/javascript">
        function checkUploadedFilesSize(progressArea, args) {
            //progressArea.confirmed is a custom variable,   
            // you can use another if you want to   
            if (!progressArea.confirmed &&
            args.get_progressData().RadUpload.RequestSize > 1000000) {
                if (confirm("The total size of the selected files" +
                          " is more than the limit." +
                                            " Do you want to cancel the upload?")) {
                else {
                    progressArea.confirmed = "confirmed";
    <telerik:RadUpload runat="server" id="RadUpload1" />
    <telerik:RadProgressArea runat="server" id="RadProgressArea1"  OnClientProgressUpdating="checkUploadedFilesSize" />
    <telerik:RadProgressManager runat="server" id="RadProgressManager1" />
    <asp:Button runat="server" id="Button1" text="Upload" />


    protected void RadUpload1_FileExists(object sender, UploadedFileEventArgs e)
        UploadedFile file = e.UploadedFile;
        string targetFileName = Server.MapPath(RadUpload1.TargetFolder) + RadUpload1.UploadedFiles[0].GetName();
        file.SaveAs(Server.MapPath(@"Upload" + @"\" + targetFileName));


    <?xml version="1.0"?>
            <add key="Telerik.ScriptManager.TelerikCdn" value="Disabled"/>
            <add key="Telerik.StyleSheetManager.TelerikCdn" value="Disabled"/>
            <compilation debug="true" targetFramework="4.0"/>
                    <add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI"/>
                <add path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" validate="false"/>
                <add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" validate="false"/>
                <add path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false"/>
                <add path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" validate="false"/>
                <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false"/>
                <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule"/>
                <add name="RadCompression" type="Telerik.Web.UI.RadCompression"/>
            <validation validateIntegratedModeConfiguration="false"/>
            <modules runAllManagedModulesForAllRequests="true">
                <remove name="RadUploadModule"/>
                <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" preCondition="integratedMode"/>
                <remove name="RadCompression"/>
                <add name="RadCompression" type="Telerik.Web.UI.RadCompression" preCondition="integratedMode"/>
                <remove name="ChartImage_axd"/>
                <add name="ChartImage_axd" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" preCondition="integratedMode"/>
                <remove name="Telerik_Web_UI_SpellCheckHandler_axd"/>
                <add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode"/>
                <remove name="Telerik_Web_UI_DialogHandler_aspx"/>
                <add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode"/>
                <remove name="Telerik_RadUploadProgressHandler_ashx"/>
                <add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode"/>
                <remove name="Telerik_Web_UI_WebResource_axd"/>
                <add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" preCondition="integratedMode"/>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Sep 2011 Link to this post

    Hello Dick,

    You can try the approach in the following help article.
    Checking File Size on the Client.

  3. Telerik UI for ASP.NET Core is out
  4. Dick
    Dick avatar
    36 posts
    Member since:
    Sep 2007

    Posted 19 Sep 2011 Link to this post

    Hi Shinu,

    Thank you for your reply, but this is the exact example that we used and doesn't work.
  5. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 19 Sep 2011 Link to this post

    Hello Dick,

    As the help topic notes, the page continues to upload the file even though the confirmation dialog is showing. So I have to assume your uploading a file that doesn't take very long to upload, but is above 4MB in size, so the max file size is reached and the error appears.

    I would re-order your code and just cancel the request and then display an alert that the file size has been reached. Either that, or increase the maxRequestLength in your web.config and see if that helps.

    I hope that helps.
  6. Dick
    Dick avatar
    36 posts
    Member since:
    Sep 2007

    Posted 21 Sep 2011 Link to this post

    Hi Kevin,

    The confirmation dialog popup never shows. We recieve a filesize exceeded error right away.

  7. Genady Sergeev
    Genady Sergeev avatar
    1595 posts

    Posted 26 Sep 2011 Link to this post

    Hello Dick,

    Please consult with the following help article showing how to configure for large file uploads in IIS7+

    Kind regards,
    Genady Sergeev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top