The FileUpload control in .Net 2.0 is rendered in browser as
html input="file"
One drawback of this control is that, if we look into the OpenFileDialog and OpenSaveDialog there will be filter. Filters allows us to display particular
file type. But in FileUpload control we don't have this filter option.
One way to get rid of this is using Regular Expression Validator.
We can use the following regular expression.
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.csv|.CSV|.xls|.XLS|.xlsx|.XLSX)$"
Now in server side we can upload the file using
FileUpload.SaveAs() method.
We can get the current path using the Server.MapPath method
string filepath = Server.MapPath("tempcsv");
fileUploadCSV.SaveAs(fileName);
done.
Tuesday, May 27, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment