Solved

Regular Expression For uploading Doc, RTF, and Txt files

Posted on 2006-11-22
2
563 Views
Last Modified: 2012-06-27
I have an upload form that needs to upload resumes. I only want to accept the following file types.

rtf, doc, txt and if possible provide a seperate error if the member trys to upload a .docx file.

The docx file is due to MS new Word 2007 I know not too many people have it now but by time I get this site completed it will be more prominate.

 

So anyhow the overall question is what would the regularexpression be for this?
0
Comment
Question by:Scripter25
2 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17998728
Here is a VB.NET example without using regular expressions:

Imports System.IO

...

        Dim fileName As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\Document1.doc"
        Dim info As New FileInfo(fileName)
        Dim ext As String = info.Extension.ToLower()
        If ext = "doc" OrElse ext = "rtf" OrElse ext = "txt" Then

        End If

Bob
0
 
LVL 6

Accepted Solution

by:
badalpatel earned 500 total points
ID: 18001074
this is the RE for checking doc,rtf,txt format..

<asp:RegularExpressionValidator ID="RegularExpressionValidator8" runat="server" ControlToValidate="FU_Image"
                            ErrorMessage="Invalid File Type" Font-Names="Verdana" Font-Size="XX-Small" ValidationExpression="^([a-zA-Z]\:|\\)\\([^\\]+\\)*[^\/:*?'<;>;|]+\.(doc|rtf|txt)(l)?$"></asp:RegularExpressionValidator>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now