Filter File extension With FileUpload

后端 未结 5 2583
醉梦人生
醉梦人生 2021-02-19 22:20

I am writing an asp.net web app which involves the use of the FileUpload control.

Right now, this particular FileUpload control only expects .z

相关标签:
5条回答
  • 2021-02-19 22:37

    I believe it is not possible.Filter by file type in browser is not control by asp.net.It is a browser functionality.

    This question already asked in stackoverflow.Please click filter the file type with the file upload control

    0 讨论(0)
  • 2021-02-19 22:40

    To select images in fileupload control..

    hope it will help you

    asp:RegularExpressionValidator ID="rexp" runat="server" ControlToValidate="fupProduct"
         ErrorMessage="Only .gif, .jpg, .png, .tiff and .jpeg"
         ValidationExpression="(.*\.([Gg][Ii][Ff])|.*\.([Jj][Pp][Gg])|.*\.([Bb][Mm][Pp])|.*\.([pP][nN][gG])|.*\.([tT][iI][iI][fF])$)"></asp:RegularExpressionValidator
    
    0 讨论(0)
  • 2021-02-19 22:42

    It's possible on client-side! But, remember to do the server-side validation.

    This two links show it: http://aspalliance.com/1614_Adding_Filter_Action_to_FileUpload_Control_of_ASPNET_20.all http://www.codeshode.com/2011/07/validate-file-extension-for-aspnet.html

    0 讨论(0)
  • 2021-02-19 22:47

    You can try the below code.

    <asp:FileUpload ID="UploadFile" accept="image/*" multiple="false" runat="server" BorderStyle="None" />
    

    It works with modern browsers.

    Do not forget to validate the extensions using code behind procedures.

    0 讨论(0)
  • 2021-02-19 22:53

    you can create validate file extension from the ASP.NET FileUpload Control

    I believe you could go for this solution

    Validate File Extension for ASP.NET FileUpload Control

    0 讨论(0)
提交回复
热议问题