Maximum file size from web.config

5 posts, 0 answers
  1. Jagadeeswararao
    Jagadeeswararao avatar
    15 posts
    Member since:
    Sep 2013

    Posted 18 Dec 2013 Link to this post

    Hi ,
     How can i get maximum file size from web.config and assign it to  RadAsyncUpload.?
     I have multiple file to upload , in case of the files or file limit exceeds 100MB then system should show an error message. how can i implement this.?
    Can you please someone help in this .... :)

    Thanks ,
    Jagadeeswararao Chappa.
     
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 18 Dec 2013 Link to this post

    Hello Jagadeeswararao,

    Please take a look at the following help article where you can get more detailed information on how you can upload large file with the RadAsyncUpload control - Uploading Large Files.

    Regards,
    Kate
    Telerik
    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 the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jagadeeswararao
    Jagadeeswararao avatar
    15 posts
    Member since:
    Sep 2013

    Posted 18 Dec 2013 Link to this post

    Thanks for response..
     but what i need exactly is:
      1) I need to upload multiple files which shouldn't crossed total size to 100MB.
      2) In case i have uploaded 50MB(not submitted), then i tried to upload a file having size 60MB shouldn't allow(as the total size will be 110MB) and error message should display.
    Any solutions for this.

  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Dec 2013 Link to this post

    Hi Jagadeeswararao,

    Please have a look into the following code I tried to achieve your scenario from C# code. As per the following code if the total upload size exceeds 100MB, then rest of the files wont get uploaded to the server and an alert is displayed to the user.

    ASPX:
    <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" Skin="Silk" TargetFolder="~/Images/Img/"
        OnClientFileUploading="OnClientFileUploading" AllowedFileExtensions=".jpg,.zip"
        MultipleFileSelection="Automatic" UploadedFilesRendering="BelowFileInput"
        OnFileUploaded="RadAsyncUpload1_FileUploaded">
    </telerik:RadAsyncUpload>
    <br />
    <telerik:RadButton ID="RadButton1" runat="server" Text="Upload" OnClick="RadButton1_Click">
    </telerik:RadButton>
    <asp:HiddenField ID="HiddenField1" runat="server" />

    C#:
    const int MaxTotalBytes = 104857600;
    Int64 UploadedBytes;
    protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
    {
        UploadedBytes += e.File.ContentLength;
        if (UploadedBytes <= MaxTotalBytes)
        {
            string targetfolder = RadAsyncUpload1.TargetFolder;
            e.File.SaveAs(Path.Combine(Server.MapPath(targetfolder), e.File.FileName));  
        }
        else
        {
            e.IsValid = false;
            UploadedBytes -= e.File.ContentLength;
            HiddenField1.Value = HiddenField1.Value + e.File.FileName + ", ";
        }
    }
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(HiddenField1.Value))
        {
            Response.Write("<script>alert('" + HiddenField1.Value + "'+' not uploaded since total file size exceeds 100MB.')</script>");
        }
        HiddenField1.Value = "";
    }

    Hope this helps,
    Shinu.
  6. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 23 Dec 2013 Link to this post

    Hi Jagadeeswararao,

    The article that i previously provided describes in details you can enable file upload for large files. Considering your other questions you can implement validation and check the size of the files that you are uploading. Take a look at this example to get a better understanding how validation works with the RadAsyncUpload.

    Regards,
    Kate
    Telerik
    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 the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017