pptx文件的FileUpload的代码是什么 [英] What is the code for FileUpload of pptx files
本文介绍了pptx文件的FileUpload的代码是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们,
我是ASP.NET中的新手.我需要有关仅接受pptx文件的FileUpload的代码是什么的帮助,并且在上载时,该文件将显示在GridView中.非常感谢!
Hi friends,
I am kind of a newbie in the ASP.NET. I need help as to what is the code for FileUpload that only accepts a pptx file, and when uploaded, the file will be displayed in the GridView.. Thanks so much!
推荐答案
使用fileuploader(asp.net)上传文件
以下是仅验证.pptx文件的代码
Use fileuploader(asp.net) to upload a file
below is the code to validate only .pptx file
if (FileUpload1.HasFile)
{
string strFileExtension = Path.GetExtension(FileUpload1.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; //to generate unique file name
FileUpload1.SaveAs(filepath + "/" + fileName);
}
else
{
lblMessage.Text = "upload only pptx file";
return;
}
}
}
这篇关于pptx文件的FileUpload的代码是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文