Normal 0
This function allows you to upload a Microsoft Word file and put it on the server using ASP.NET.
Normal 0 Add the following controls to the aspx file, inside a form tag:The code behind file:
protected void upload_file_Click (object sender, EventArgs e)
{
bool val = false;
int x = uploader.FileName.LastIndexOf('.');
int y = uploader.FileName.Length;
string file_ext = uploader.FileName.Substring(x, (y - x));
if (uploader.HasFile)
{
if ( (file_ext == ".doc"))
{
uploader.SaveAs(Server.MapPath("~/") + uploader.FileName);
msg.Text = " File successfully uploaded";
}
else
{
msg.Text = "Error. Please choose a document to upload";
}
}
}




