Thread is closed for posting
2 posts, 0 answers
  1. jayanthi
    jayanthi avatar
    111 posts
    Member since:
    Jul 2010

    Posted 30 May 2013 Link to this post


    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?

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

    Posted 30 May 2013 Link to this post


    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.

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

    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.

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

Back to Top