This is a migrated thread and some comments may be shown as answers.

RadAsyncUpload MaxFileSize Issue

5 Answers 395 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
James Brown
Top achievements
Rank 1
James Brown asked on 14 Jan 2011, 08:18 PM
Hello,

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.

Also,
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>
  </head>
  <body>
    <form id="form1" runat="server">
      <div>
        <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">
          <tr>
            <td>
              <asp:Button ID="btnUpload" runat="server" Text="Upload Files" />
            </td>
          </tr>
        </table>
      </div>
    </form>
  </body>
</html>

---- 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)
        CN.Open()


        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)
            cmd.ExecuteNonQuery()
            'sdsFiles.DataBind()
            'gvFiles.DataBind()
        Next
        CN.Close()
    End Sub
End Class

Any assistance is greatly appreciated,

Thanks

5 Answers, 1 is accepted

Sort by
0
Accepted
Cori
Top achievements
Rank 2
answered on 17 Jan 2011, 02:17 PM
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.
0
James Brown
Top achievements
Rank 1
answered on 17 Jan 2011, 02:30 PM
That did the trick...... Thanks
0
Chandrashekhar
Top achievements
Rank 1
answered on 06 Feb 2013, 02:22 PM
How can I increase max file size to 10 mb? what are the file changes I need to do?
0
Shinu
Top achievements
Rank 2
answered on 08 Feb 2013, 12:40 PM
Hi Chandrasekhar

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

Thanks
Shinu
0
Hristo Valyavicharski
Telerik team
answered on 08 Feb 2013, 04:08 PM
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.

Regards,
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.
Tags
Upload (Obsolete)
Asked by
James Brown
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
James Brown
Top achievements
Rank 1
Chandrashekhar
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Hristo Valyavicharski
Telerik team
Share this question
or