473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

file extension validation

Hi ,
I want to validate the file extension (.pdf) in through "RegularExpressionValidator" (asp.net) .I am not able to decide what
ValidationExpression shall i use.
Please help.
Manohar
Feb 13 '08 #1
5 1452
debasisdas
8,127 Expert 4TB
You need to check for the part after the " . " from right side of the filename.
Feb 13 '08 #2
You need to check for the part after the " . " from right side of the filename.
Yes I need to check the extension of file.
I am using validationExpression="/^.+(\.(pdf))$"
But its not working.
Regards,
Manohar
Feb 13 '08 #3
r035198x
13,262 8TB
Yes I need to check the extension of file.
I am using validationExpression="/^.+(\.(pdf))$"
But its not working.
Regards,
Manohar
If you have the file name in a string variable, you can use
Expand|Select|Wrap|Line Numbers
  1. if(fileName.EndsWith(".pdf"))
Feb 13 '08 #4
If you have the file name in a string variable, you can use
Expand|Select|Wrap|Line Numbers
  1. if(fileName.EndsWith(".pdf"))
I have file path stored in a variable.But this code works in code file.I need to do it from client side (java Script).
I wrote a function and achive the result.
But i want another solution.
Regards,
Manohar
Feb 13 '08 #5
Gyanender,

U can use the below example as reference...

<asp:RegularExpressionValidator
id="RegularExpressionValidator1" runat="server"
ErrorMessage="Only mp3, m3u or mpeg files are
allowed!" ValidationExpression="^(([a-zA-
Z]:)|(\\{2}\w+)\$?)(\\(\w[\w
].*))+(.mp3|.MP3|.mpeg|.MPEG|.m3u|.M3U)$"
ControlToValidate="File1">
</asp:RegularExpressionValidator>

As ur case is to check for .pdf extension, then just repalce +(.mp3|.MP3|.mpeg|.MPEG|.m3u|.M3U) with +(.pdf|.PDF)

Regards,
Sameer
Feb 13 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Chris Kennedy | last post by:
Does anyone know a regular expression that will validate the file extension but also allow multiple file extensions if necessary. It also needs to be case insensitive. Basically, what I want is to...
2
by: chuckdfoster | last post by:
I have a page that users upload files. Is there a way to restrict the file types that they can upload? thanks, -- Chuck Foster Programmer Analyst Eclipsys Corporation - St. Vincent Health...
3
by: ciaran.mchale | last post by:
Hi folks, I downloaded the binary version of Xerces C++ 2.7.0 for Windows and am using it to help me get up to speed with XML and XML Schema. So please excuse me if this is a "novice" question....
0
by: Amar | last post by:
I am recieving the "The root element is missing" error from my soap extension while attempting to validate an incoming SOAP message request. I suspect the problem resides in the ChainStream method...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
5
by: Smarty | last post by:
Dear Friends, I did a file type validation in Javascript. Just i want to check whether a selected file is BMP or JPG. I wrote the following function for it. function checkType(){ Text =...
2
by: =?Utf-8?B?TW9uaWNh?= | last post by:
Hi, I want when I click on Browse button (FileUpload Control), I see just image extensions not anything else. How can I do this? Thanks, Monica
5
by: jimchapuk | last post by:
I just started to learn. I can't get the code in my CSS file to link to my HTML file to produce the web page I want. The code I've used is; <link rel="stylesheet" type="txt/css"...
10
by: jonathan184 | last post by:
Hi I am tryin to validate certian types of files to be uploaded and file size and if this follows this correctly then insert in db this is the code i did so far. So far I commented out the parts...
2
by: gyanendar | last post by:
Hi , I want to validate the file extension (.pdf) in through "RegularExpressionValidator" (asp.net) .I am not able to decide what ValidationExpression shall i use. Please help. Manohar
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.