troubleshooting Question

FileUploadControl RegularExpressionValidator to only accepts images, dwg, and pdf and exclude ampersands

Avatar of Jonathan Mori
Jonathan MoriFlag for United States of America asked on
.NET ProgrammingASP.NETRegular Expressions
6 Comments1 Solution677 ViewsLast Modified:
Hi, I am trying to figure out a way to limit the fileupload control to only accept certain types of files. These include jpg, gif, png, pdf, and dwg. Also To prevent ampersands in the filename.
I am having trouble getting the regular expression correct.
<asp:RegularExpressionValidator id="FileUpLoadValidator" runat="server" 
                ErrorMessage="Please Only Upload PDF, Image, or DWG files." 
                ValidationExpression="(?:\\\w+)+\.(?:jpg|JPG|gif|GIF|PDF|pdf|DWG|dwg)$/\.(?:jpg|gif|pdf|dwg)$/i"
                ControlToValidate="DocUpload">
</asp:RegularExpressionValidator>
ASKER CERTIFIED SOLUTION
Stephan
Lead Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros