Hi,
I have a File Upload Control in a form and it allows only selected file types.
I implemented this on the
button_click event of the page.
In
web config:
<appSettings>
<add key="FileSize" value="2097152"/>
<add key="FileType" value=".txt,.xlsx,.xls,.docx,.doc,.ppt,.pptx,.pdf"/>
</appSettings>
In
btnSubmit_Click():
string[] allowExtentions = (ConfigurationManager.AppSettings["FileType"]).Split(',');
if (allowExtentions.Contains(Path.GetExtension(FileUp.PostedFile.FileName)) || Path.GetExtension(FileUp.PostedFile.FileName) == "")
{
}
Is there any other way to implement the file type restrictions of File Upload Control ?? Please Help
Cos, I want it to
check before postback of the page.
In this implementation, it accepts the file first and later throws an error message on a label after the post back which I don't want.
Waiting for your valuable comments.
Thanks,
Phanindra Bitla