ASP.NET - Limit file upload available file types

后端 未结 10 1242
忘了有多久
忘了有多久 2020-12-13 14:28

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 a

10条回答
  •  别那么骄傲
    2020-12-13 14:54

    As stated above, it's not possible out of the box.

    The simpler solution that I've found: use a RegularExpressionValidator to check the file extension. No need for JavaScript or external libraries. Of course, it only checks the extension, not the file content (you must use server-side code and inspect the bytes), and does not change anything to the file list displayed in the folder browser.

    
    

提交回复
热议问题