Learn how to a build a cloud-first strategyRegister Now


Trouble with fileupload control and regularexpressionvalidation

Posted on 2014-08-29
Medium Priority
Last Modified: 2014-08-30
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.
Question by:derrekdeveloper
LVL 31

Accepted Solution

MlandaT earned 2000 total points
ID: 40293641
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

ID: 40294374
Perfect! Thank you.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month20 days, 20 hours left to enroll

810 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