A
ad
How can we assign file extension using FileUpload?
I want to uer upload a excel file, I want to limit the file extension to
".xls"
Sreejith Ram said:you can use a asp:RegularExpressionValidator to validate file extensions
a sample regular expression for XSL and CSV is
^[0-9A-Za-z_ ]+(.[xX][lL][sS]|.[cC][sS][vV])$
i am not good in regular exps, following site got lot of samples
http://www.regexlib.com/REDetails.aspx?regexp_id=259
Mark Rae said:protected HtmlInputFile txtFileName;
if(Path.GetExtension(txtFileName.PostedFile.FileName) != ".xls"
{
// do something
}
ad said:I have tried the RegularExpressionValidator , but no effect!
Sreejith Ram said:you can use a asp:RegularExpressionValidator to validate file extensions
a sample regular expression for XSL and CSV is
^[0-9A-Za-z_ ]+(.[xX][lL][sS]|.[cC][sS][vV])$
i am not good in regular exps, following site got lot of samples
http://www.regexlib.com/REDetails.aspx?regexp_id=259
Mark Rae said:I want to uer upload a excel file, I want to limit the file extension to
".xls"
protected HtmlInputFile txtFileName;
if(Path.GetExtension(txtFileName.PostedFile.FileName) != ".xls"
{
// do something
}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.