Response to: What is the code for FileUpload of pptx files
Revision 1
Use fileuploader(asp.net) to upload a file
below is the code to validate only .pptx file
if (UploadIcon.HasFile)
{
string strFileExtension = Path.GetExtension(UploadIcon.PostedFile.FileName);
if (strFileExtension != null)
{
string validFileExtension = strFileExtension.ToLower();
if (validFileExtension == ".pptx")
{
string filepath = Server.MapPath("~/Images");
if (!Directory.Exists(filepath ))
{
Directory.CreateDirectory(imagePath);
}
string fileName = Guid.NewGuid().ToString().Replace("-", "") + strFileExtension;
UploadIcon.SaveAs(filepath + "/" + fileName);
}
else
{
lblMessage.Text = Common.DisplayMessage("Please upload only jpg, jpeg, gif, png format",
MessageType.ErrorMessage, 5, DisplayStyle.None);
return;
}
}
}
Posted 13-Sep-12 22:31pm
by
Azziet.