Solved

Regular Expression For uploading Doc, RTF, and Txt files

Posted on 2006-11-22
2
558 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

747 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

13 Experts available now in Live!

Get 1:1 Help Now