File extension validation from C# code behind for Asp.net file upload control
File extension upload validation from C# code behind for Asp.net file upload control
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
arjunan selvam5 reputationPosted Sep 24, 2012, 1:57 AM EDT
FileUpload
Simple validation using javascript.
Vithal WadjeRank #19 · 47.2K reputationPosted Oct 23, 2012, 2:42 AM EDT
if (FileUpload1.HasFile)
{
try
{
switch (ext)
{
case ".xls":
type = "application/vnd.ms-excel";
break;
case ".xlsx":
type = "application/vnd.ms-excel";
break;
}