M.L. Martin
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-B6 39-385DB8E 05A26.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:RegularExpressionVali dator ID="uplValidator" runat="server" ControlToValidate="FileUpl oad1"
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:Regu larExpress ionValidat or><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.
<asp:FileUpload type="file" ID="FileUpload1" runat="server" Width="180px" /><br />
<asp:RegularExpressionVali
ErrorMessage="Your video format is not supported"
ValidationExpression="^([0
<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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER