I have added a file upload to my asp.net website. However, I want to limit the file types that user can select. For example, I only the user to select mp3 files. How can I add a filter to the file upload so that it displays only the mp3 files in the folder selected?
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnAudUpload" Text="Upload" CssClass="btncssUpload" OnClick="btnAudUpload_Click" runat="server" />
This is probably a very old topic, however if anyone else has this question I found that this worked for me
because asp:FileUpload converts to a html tag on client side, it logically makes sence that you can add html tags aswell.
It worked for me, now you can only select those file tipes and don't need the regular expressions
There is no problem. Here it is!
Using RegularExpressionValidator may help you. No serverside code is necessary for the checking of the file extension. Check out this code
Remember all you have to do is now add a fileupload control with the id FileUpload1. Done. You can press F5 and see the effect
It's not possible with the FileUpload control in ASP.NET, but the following link may help:
http://forums.asp.net/p/1136820/1817938.aspx