Trouble with fileupload control and regularexpressionvalidation

I have an asp.net 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.
derrekdeveloperAsked:
Who is Participating?
 
MlandaTCommented:
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:

ValidationExpression="^.*\.(mov|MOV|m4v|M4V|avi|AVI|wmv|WMV|mp4|MP4)$"

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]
0
 
derrekdeveloperAuthor Commented:
Perfect! Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.