How check multiple (dot) of file name in javascript [Resolved]

Posted by Cpatil1000 under ASP.NET on 9/23/2016 | Points: 10 | Views : 342 | Status : [Member] | Replies : 2
hi,

I want check before upload a file with extention name. Most I likely to upload
only pdf file not another file like txt, doc, xls or other. If someone type upload
file with multiple dot extention. i.e. aabc.pdf.phf or aabc.php.pdf Such type of file
shold not load. only allowed file as like aabc.pdf.




Responses

Posted by: Rajnilari2015 on: 9/24/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
Try this

        var file = "aabc.php.pdf"
var fileExtension = file.substring(file.lastIndexOf(".")+1)
if(fileExtension === "pdf") {alert('its a pdf file');}
else {alert('its not a pdf file');}


--
Thanks & Regards,
RNA Team

Cpatil1000, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sheonarayan on: 9/23/2016 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Hi Cpatil1000,

Here is the article I had written long back http://www.dotnetfunda.com/articles/show/981/multiple-files-upload-in-aspnet-and-aspnet-with-jquery that will solve your problem.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Cpatil1000, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response