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

Maximum file size from web.config

4 Answers 193 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Jagadeeswararao
Top achievements
Rank 1
Jagadeeswararao asked on 18 Dec 2013, 12:15 PM
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.
 

4 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 18 Dec 2013, 02:58 PM
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.
0
Jagadeeswararao
Top achievements
Rank 1
answered on 19 Dec 2013, 05:19 AM
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.

0
Shinu
Top achievements
Rank 2
answered on 23 Dec 2013, 01:56 PM
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.
0
Kate
Telerik team
answered on 23 Dec 2013, 02:29 PM
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.
Tags
AsyncUpload
Asked by
Jagadeeswararao
Top achievements
Rank 1
Answers by
Kate
Telerik team
Jagadeeswararao
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or