Wrox Home  
Search P2P Archive for: Go

  Return to Index  

html_code_clinic thread: RE: How to specify file types in a file input


Message #1 by Chris Ullman <chrisu@w...> on Wed, 23 Aug 2000 13:34:04 +0100
>>I have a form in which i am using the file Input type. I want users to 
>>select only HTM files (*.htm). How can i specify that filter in file 
>>input type ?

Great question, I'm not sure what the answer is! Currently, the TYPE=FILE
selection of the INPUT tag produces a text box with a browse button. The
browse button sends you to a dialog would allow you to select either gif
files, htm files or all documents. I'm not sure what would let you restrict
it to just HTML, certainly there's nothing else in the INPUT tag that would
help you in HTML 4.0. What I'd consider is using ASP instead (if available
to you). 

You could use the <SELECT> tag in place of input to produce a true HTML text
box that only allowed you to return .html.  e.g.

<FORM METHOD=POST ACTION="return.asp">
<INPUT TYPE=TextBox NAME=FileName>
<SELECT NAME="FileType">
<OPTION>HTML Files (*.htm)(*.html)</OPTION>
</SELECT>
</FORM>

Then you could use ASP to append the choice of file extension to your file
name, and check whether this file existed or not using the FileSystem
object.

Chris



  Return to Index