RadAsyncUpload MaxFileSize Issue

Thread is closed for posting
6 posts, 1 answers
  1. James Brown
    James Brown avatar
    2 posts
    Member since:
    Apr 2010

    Posted 14 Jan 2011 Link to this post


    I have a RadAsyncUpload control on a webpage which opens in a radwindow and inserts the files into a database table.  It works great and displays a checkmark unless you select a file larger than 5MB in which case you get an exclamation mark with no errors (javascript or otherwise).
    The MaxFileSize is set to 0 (which should be unlimited) yet it does not work in developement or production.

    Is there a way to have the control clear the temp file from the RadUploadTemp folder when the remove link is clicked or after i have put the files in the database?

    ---- UPLOADFORM.ASPX ----
    <%@ Page Language="VB" Theme="Main" AutoEventWireup="false" CodeFile="UploadForm.aspx.vb" Inherits="UploadForm" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!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>Upload Contract</title>
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="Script1" runat="server" />
            <telerik:RadFormDecorator ID="tfd1" runat="server" />
            <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Forest" />
            Select file(s) to upload for Customer # <asp:Label ID="lblCustomerNumber" runat="server" Text="" />
            <telerik:RadAsyncUpload ID="RadUpload1" runat="server" Skin="Forest" 
              ControlObjectsVisibility="RemoveButtons" MaxFileSize="0" 
              InputSize="40" MaxFileInputsCount="3" Width="475px" />
            <br />
            <table align="center">
                  <asp:Button ID="btnUpload" runat="server" Text="Upload Files" />

    ---- UPLOADFORM.ASPX.VB ----
    Imports Telerik.Web.UI
    Imports System.Data.Sql
    Imports System.Data.SqlClient
    Imports System.Data.SqlTypes

    Partial Class UploadForm
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            lblCustomerNumber.Text = Session("CustomerID")
        End Sub

        Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
            Dim CN As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("EnergyConnectionString").ToString)

            For Each File As UploadedFile In RadUpload1.UploadedFiles
                Dim bytes(File.ContentLength - 1) As Byte
                File.InputStream.Read(bytes, 0, File.ContentLength)
                Dim cmd As New SqlCommand("INSERT INTO ContractFiles (CustomerID, FileName, FileExt, MIMEType, FileSize, DateAdded, FileData) VALUES (@CID, @FN, @FE, @MT, @FS, @DA, @FD)", CN)
                cmd.Parameters.AddWithValue("@CID", "2976")
                cmd.Parameters.AddWithValue("@FN", File.GetNameWithoutExtension())
                cmd.Parameters.AddWithValue("@FE", File.GetExtension().ToString.Replace(".", ""))
                cmd.Parameters.AddWithValue("@MT", File.ContentType())
                cmd.Parameters.AddWithValue("@FS", File.ContentLength.ToString())
                cmd.Parameters.AddWithValue("@DA", Now.ToString())
                cmd.Parameters.AddWithValue("@FD", bytes)
        End Sub
    End Class

    Any assistance is greatly appreciated,

  2. Answer
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 17 Jan 2011 Link to this post

    Hello James,

    Setting the MaxFileSize on the RadAsyncUpload control, requires you to modify the maxRequestLength in your web.config file. The maxRequestLength is defaulted at around 4MB and it's the reason your 5MB file doesn't get uploaded.

    I hope that helps.
  3. DevCraft R3 2016 release webinar banner
  4. James Brown
    James Brown avatar
    2 posts
    Member since:
    Apr 2010

    Posted 17 Jan 2011 Link to this post

    That did the trick...... Thanks
  5. Chandrashekhar
    Chandrashekhar avatar
    4 posts
    Member since:
    Dec 2012

    Posted 06 Feb 2013 Link to this post

    How can I increase max file size to 10 mb? what are the file changes I need to do?
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Feb 2013 Link to this post

    Hi Chandrasekhar

    Try the following markup to increase the max file sizes
    Here as an example I have given 10mb..
      .. ... ... ........ ....
        <httpRuntime maxRequestLength="10240"/>
      .. ... ... ........ ....

  7. Hristo Valyavicharski
    Hristo Valyavicharski avatar
    975 posts

    Posted 08 Feb 2013 Link to this post

    Hi Chandrasekhar,

    Shinu's suggestion is good one. By default, IIS7 limits file upload to 30MB. RadAsyncUpload's documentation will give you better understanding how to configure your web.config file to upload larger files.

    I hope this helps.

    Hristo Valyavicharski
    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
DevCraft R3 2016 release webinar banner