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

Radupload

1 Answer 237 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Akhilesh
Top achievements
Rank 1
Akhilesh asked on 24 Dec 2007, 07:10 AM
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

1 Answer, 1 is accepted

Sort by
0
Sophy
Telerik team
answered on 27 Dec 2007, 12:56 PM
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
Tags
Upload (Obsolete)
Asked by
Akhilesh
Top achievements
Rank 1
Answers by
Sophy
Telerik team
Share this question
or