Link to home
Start Free TrialLog in
Avatar of M.L. Martin
M.L. MartinFlag for United States of America

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of M.L. Martin

ASKER

Perfect! Thank you.