文件上传选项更改 [英] file upload options changing

查看:76
本文介绍了文件上传选项更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

请帮助我如何更改文件上传选项,

例子.当用户想要附加文件时,他将单击浏览"选项,将出现一个弹出窗口,要求用户选择文件,在底部将出现一个下拉列表,以选择文件类型.

在那里,我只想让JPG和GIF剩下的所有内容都不显示在下拉菜单中,如何修改该弹出窗口?

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 ?

推荐答案

您无法设置特定的扩展名在标准文件打开对话框中进行过滤,而不是您可以使用javascript:
在客户端检查验证
请参考以下内容:
http://www.codeproject.com/KB/webforms/AnimatedImageUploader.aspx

谢谢,
Imdadhusen
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


为什么在上载时不通过扩展其扩展名来检查文件类型:

检查样品:
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>");
               }
           }
       }


这篇关于文件上传选项更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆