Click here to Skip to main content
15,911,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

Please help me how to change file upload options,

Example. when the user want to attach the file he will click on browse option there a pop will exist and ask the user to select the file, in bottom there will be drop down, to select type of file.

There i want to give JPG and GIF only remaining all should not show in drop down, how to modify that popup window ?
Posted

You can't set specific extensions filtration on standard file open dialog instead of you can check validation on client side using javascript:

Please refer following:
http://www.codeproject.com/KB/webforms/AnimatedImageUploader.aspx

Thanks,
Imdadhusen
 
Share this answer
 
v2
why don't u check the type of file while uploading by extacting its extension :

check the sample :
if (FileUpload1.PostedFile.ContentType.ToUpper().IndexOf("IMAGE") > -1)
       {
           System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
           int Width = img.Width;
           int Height = img.Height;

           if (Width > 1000 || Height > 1000 || FileUpload1.PostedFile.ContentLength > 1024 * 1024 * 200)
           {
               this.ClientScript.RegisterStartupScript(this.GetType(), "Startup",
                     "<script language='javascript'>alert('The image size is too large!');</script>");
           }
           else
           {
               if (type == "jpg" || type == "gif" || type == "bmp" || type == "JPG" || type == "GIF")
               {
                   string ImagePath = "images/";
                   string sPath = Server.MapPath(ImagePath) + dataName + fileName;
                   string imgPath = ImagePath + dataName + fileName;
                   this.FileUpload1.PostedFile.SaveAs(sPath);
                   this.ClientScript.RegisterStartupScript(this.GetType(),
                         "Startup", "<script language='javascript'>alert('Success!');</script>");
                   this.Image1.ImageUrl = imgPath;
                   this.btnSubmit.Enabled = false;
                   this.btnSubmit.Text = "Success!";
                   this.btnSubmit.Enabled = true;

               }
               else
               {
                   this.ClientScript.RegisterStartupScript(this.GetType(), "Startup",
                         "<script language='javascript'>alert('File type is not right!');</script>");
               }
           }
       }
 
Share this answer
 
v2
Comments
manoharnch 23-Sep-11 7:31am    
Already we have done this, we need the extinction in browser popup dropdown.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900