HTMLInputFile class

djdaiz

New Member
I'm trying to restrict the MIME types that users are allowed to select using an HTMLInputFile dialog box. From what I can find, the Accept property is supposed to do this, but I can't get it to work correctly. I'm using the following tag straight from the help files of Visual Studio.NET:<BR><BR><input id="btnUploadPicture" type="file" accept="image/*" runat="server"/><BR><BR>But this doesn't change the behavior at all. It allows users to select "All Files", "HTML", and "Pictures". I'm only uploading pictures, so I'd really like to restrict it to selecting pictures only. Does anyone know how to get this to work correctly?<BR><BR>Thanks,<BR> BrantonI don't think you can force a user to only be able to upload a particular MIME time. As the help docs say: "Support for this property is browser dependent. Check with your browser to determine if it supports this property." SO even if it does work with, say, IE 6, you cannot force users of other browsers to be able to upload a file of a certain MIME type.<BR><BR>What you will need to do is check the file extension on the Web server's end and decide what to do once you have the file... hthYou could also probably handle a change event on the control and inspect the file extension yourself to see if the selected file was of the proper type.
 
Back
Top