Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
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!
Posted 13-Sep-12 21:48pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Use fileuploader( 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 ))
                            string fileName = Guid.NewGuid().ToString().Replace("-", "") + strFileExtension; //to generate unique file name
                           FileUpload1.SaveAs(filepath  + "/" + fileName);
                        lblMessage.Text = "upload only pptx file";
Member 9324114 at 16-Sep-12 20:32pm
Hi, im sorry but I wanted to ask, why did you use the "UploadIcon" in the IF statement? By the way, here are the following information that I believe would contribute:
ID: FileUpload1
Database Data Type: varbinary(MAX)
The FileUpload will only accept pptx file, and when uploaded, it must appear in the GridView1.
Thank you Azziet, I appreciate your help :)
Thanks for the upcoming answers! Thanks alot!
Azziet at 26-Sep-12 1:32am
its just a fileuplaoder name (fileupload1)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 717
1 ChauhanAjay 135
2 Maciej Los 130
3 ashok rathod 90
4 ChintanShukla 90
0 Sergey Alexandrovich Kryukov 10,200
1 OriginalGriff 6,987
2 CPallini 5,850
3 George Jonsson 4,015
4 Gihan Liyanage 3,266

Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100