INPUT type=file Element | INPUT type=file Object
Creates a file upload object with a text box and Browse button.
HTML Syntax
<INPUT ACCESSKEY = key ALIGN = LEFT | CENTER | RIGHT ALT = text CLASS = classname DISABLED ID = value LANG = language LANGUAGE = JAVASCRIPT | JSCRIPT | VBSCRIPT | VBS LOWSRC = url MAXLENGTH = n NAME = name SIZE = n STYLE = css1-properties TABINDEX =n TITLE =text TYPE = FILE VALUE = value event = script >
Remarks
For a file upload to take place:
- The file element must be enclosed within a FORM element.
- A value must be specified for the NAME attribute of the file element.
- The METHOD attribute of the FORM element must be set to post.
- The ENCTYPE attribute of the FORM element must be set to multipart/form-data.
To handle a file upload to the server, a server-side process must be running that can handle multipart/form-data submissions. For example, the microsoft posting acceptor allows Microsoft® Internet Information Server to accept file uploads. Additional Common Gateway Interface (CGI) scripts that can handle multipart/form-data submissions are available on the Web.
The file element is an inline element and does not require a closing tag.
This element is available in HTML and script as of Microsoft® Internet Explorer 4.0. The file upload add-on is required to use the file element in Internet Explorer 3.02. Users can enter a file path in the text box or click the Browse button to browse the file system.
Members
Styles
Example
The following examples use the file element to upload a file to a server. The first example requires Microsoft® Posting Acceptor, which can be used with Internet Information Server (IIS) or Personal Web Server.
Sample Code
This example uses HTML code to submit a file selected by the user to Cpshost.dll, which is installed with Posting Acceptor.
<FORM NAME="oForm" ACTION="/scripts/cpshost.dll?PUBLISH?/scripts/repost.asp" ENCTYPE="multipart/form-data" METHOD="post"> <INPUT TYPE="file" NAME="oFile1"> <INPUT TYPE="text" NAME="TargetURL" VALUE="/users/"> <INPUT TYPE="submit" VALUE="Upload File"> </FORM>This example shows the Active Server Page (ASP) content of Repost.asp. Notice that the properties of the uploaded file are accessible from the submitted form.
<%@ LANGUAGE = JScript %> <% Response.buffer=true; %> <HTML> <TITLE>Repost Example</TITLE> <BODY> <H1>Upload Status</H1> <P> Destination: <B><% Response.Write(Request.Form("TargetURL")) %></B> </P> <% Response.write("<P>Name: " + Request.Form("FileName") + "</P>"); Response.write("<P>Size: " + Request.Form("FileSize") + "</P>"); Response.write("<P>Path: " + Request.Form("FilePath") + "</P>"); %> </BODY> </HTML>
See Also
INPUT, upload files to the internet information server , uploading a file to iis using a browser
Did you find this topic useful? Suggestions for other topics? write us!
© 1999 microsoft corporation. all rights reserved. terms of use.