Radupload

Thread is closed for posting
2 posts, 0 answers
  1. Akhilesh
    Akhilesh avatar
    14 posts
    Member since:
    Dec 2007

    Posted 24 Dec 2007 Link to this post

    hi i am using radupload 2.3.2

    i have added validations

    MaxFileSize

    ="204800" allowedfileextensions=".jpg,.jpeg"


    i want to throw an alert if these conditions r not met
    i tried using the onvalidatingfile but tht dosent seem to work
  2. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 27 Dec 2007 Link to this post

    Hello Akhilesh,

    First of all, I would like to ask you whether you use the classic RadUpload or you use RadUpload "Prometheus" as you say that you are using RadUpload v2.3.2 which is a version of the classic RadUpload while this is a forum thread about RadUpload "Prometheus", although in the current case there is no matter what is the RadUpload you use.

    Below I suggest you a workaround for your scenario. The suggested workaround does not depend on whether you use the classic RadUpload or you use RadUpload "Prometheus".

    ASPX/ASCX:
    <telerik:radupload id="RadUpload1" runat="server" allowedfileextensions=".jpg,.jpeg" onvalidatingfile="ValidateFile" targetfolder="~/Files"/>  
    <asp:button id="Button1" runat="server" text="Submit" /> 

    Code-behind:
    protected void ValidateFile(object sender, Telerik.Web.UI.Upload.ValidateFileEventArgs e)  
    {  
        string[] allowedExtensions = RadUpload1.AllowedFileExtensions;  
        bool allowedExtensionFlag = false;  
        for (int i = 0; i < allowedExtensions.Length; i++)  
        {  
     
            if (e.UploadedFile.GetExtension() == allowedExtensions[i])  
            {  
                allowedExtensionFlag = true;  
            }  
        }  
        if (!allowedExtensionFlag)  
        {  
            string script = "alert('Invalid files');";  
            Page.ClientScript.RegisterStartupScript(this.GetType(), "ValidateFiles", script, true);  
        }  

    You can feel free to modify the suggested code so that it serves your needs.

    Please, let me know if you need further assistance.

    Best regards,
    Sophy
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top