Trouble with fileupload control and regularexpressionvalidation

Posted on 2014-08-29
Last Modified: 2014-08-30
I have an 4.5 page that performs a file upload with a asp:Fileupload. The video file is stored in a directory and the path to the file is stored in sqlserver. I have tested multiple devices but I have trouple with the Apple iPad when I attempt. I will list my code that allows only certain file types. It seems that when I attempt to upload a .MOV file from the iPad some type of compression is performed and the iPad creates a name for the file like this: trim.D1D37BD2-0CA7-4F41-B639-385DB8E05A26.MOV. I am certain that the placing of trim is front of the file name is causing my validation code not to work. Below is my validation code:
<asp:FileUpload type="file"  ID="FileUpload1" runat="server" Width="180px" /><br />
        <asp:RegularExpressionValidator ID="uplValidator" runat="server" ControlToValidate="FileUpload1"
 ErrorMessage="Your video format is not supported"
 ValidationExpression="^([0-9a-zA-Z_\-~ :\\])+(.mov|.MOV|.m4v|.M4V|.avi|.AVI|.wmv|.WMV|.mp4|.MP4)$" Font-Names="Arial" Font-Size="8pt" ForeColor="Red"></asp:RegularExpressionValidator><br />
        <asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />

I was able to test this by removing the validation code and the file uploaded ok. I wanted to know if there was another way I should write the RegularExpressionValidator to allow uploading from the iPad. I am able to upload a .MOV file from any other devices that do not perform a re-naming of the file.
Question by:derrekdeveloper
    LVL 30

    Accepted Solution

    I think the issue is with the miltiple dots in the iPad filename. If you only want to validate the extension, then something like this will work:


    PS: I dont remember whether the matches are case sensitive or not. If you really want to make sure that even file.MoV will go through as welll then for the extensions, use something like:  [Mm][Oo][Vv]|[Aa][Vv][Ii]

    Author Closing Comment

    Perfect! Thank you.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now