Solved

Regular Expression For uploading Doc, RTF, and Txt files

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

772 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