Using JavaScript you can use regular expression to get file extension like this:
var extens=(/[.]/.exec(myfile)) ? /[^.]+$/.exec(myfile) : undefined;
myfile is the address or the path of the file. This simply takes the part of the string after "." . Then you can place some control checks with if. Something like :
if(extens=="doc" || extens=="pdf")
{
//your method goes here
}
else
{
alert("file is invalid");
}
You can also refer to this for more help:
http://www.coursesweb.net/javascript/check-file-type-before-upload_t[
^]
hope this helps :)