Ghost Posted August 2, 2003 Posted August 2, 2003 i am trying to upload files of a certain type, say image. but using the HTMLInputFile control, i cannot seem to restrict the file types. can anyone help me on this? i tried the property FileBrowser.Accept = "image/*"; on Page_Load(). this does not work. "FileBrowser" is the name of my HTMLInputFile control. Quote
Moderators Robby Posted August 2, 2003 Moderators Posted August 2, 2003 The following allows pdf, txt and zip (for example) Dim UpFile As HttpPostedFile = FileBrowser.PostedFile If ValidateUploadFileType(UpFile.ContentType.ToString) Then 'valid else 'not valid end if Private Function ValidateUploadFileType(ByVal txt As String) As Boolean If txt.IndexOf("text/plain") > -1 OrElse txt.IndexOf("x-zip") > -1 OrElse txt.IndexOf("pdf") > -1 Then Return True Else Return False End If End Function Quote Visit...Bassic Software
Ghost Posted August 2, 2003 Author Posted August 2, 2003 using wildcard Thank you for the reply. But what i want to do is, give a wildcard character or something so that i dont have to specify the extension name each time in the IF condition. Say, i want all IMAGE types - it would be nice if i could just mention "*" or something so that the FILE DIALOG box which pops up shows only those image file options in the "FileTypes". Get what i mean? Quote
Moderators Robby Posted August 2, 2003 Moderators Posted August 2, 2003 Sorry I misunderstood your question. I would put a bunch of OrElse together and list the types (jpg,gif, bmp, etc) For example, I wouldn't allow PCX format. (but that's just me) Quote Visit...Bassic Software
*Gurus* Derek Stone Posted August 2, 2003 *Gurus* Posted August 2, 2003 Very few of the current Web browsers support the specifying of file types in the file input tag. You're pretty much out of luck in that regard. You'll have to filter at the server. Quote Posting Guidelines
Ghost Posted August 4, 2003 Author Posted August 4, 2003 Thank you, people. I also read somewhere that the ACCEPT property of the HTMLFileInput class works only for Netscape and not for IE. If anyone gets any further info on the same / if it is possible in any way, please revert. Thanks. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.