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

Radupload

1 Answer 74 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
jayanthi
Top achievements
Rank 1
jayanthi asked on 30 May 2013, 08:50 AM
Hello,

1. I need the image filter (ie, it must allow only image files) when i click Select Button in RAD UPLOAD control and not in validation.

2. I change "a.doc" files extension as "a.jpeg" and trying to upload the "a.jpeg" file. How to stop uploading the a.jpeg file as because it's not an image file.
How to do validation using java script?

Regards
Jayanthi

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 May 2013, 11:55 AM
Hi,

Try setting the AllowedFileExtensions property of the RadUpload which lists the valid file extensions for uploaded files. When the AllowedFileExtensions property is set, RadUpload automatically validates the extensions of selected files, moving any files with disallowed extensions to the InvalidFiles collection.

ASPX:
<telerik:RadUpload ID="RadUpload1" TargetFolder="~/uploads/" AllowedFileExtensions=".jpg" runat="server">
</telerik:RadUpload>

As far as I know, your second requirement is not possible with JavaScript. One suggestion is you can try the following server side code which validates an image by extracting image data from the byte array.

C#:
try
{
 
    System.Drawing.Image image1 = System.Drawing.Image.FromFile("E:\\Pic1.jpg");
    if (image1.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg))
    {
        Label1.Text = "JPEG";
    }
    else
    {
        Label1.Text = "Other Picture File";
    }
}
catch (Exception ex1)
{
    Label1.Text = "Invalid File";
}

Thanks,
Shinu.
Tags
Upload (Obsolete)
Asked by
jayanthi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or