input type=file element | input type=file object
[This documentation is preliminary and is subject to change.]
Creates a file upload object with a text box and Browse button.
![]() |
Standards information
- HTML 4.01 Specification, Section 17.4
HTML information
| Closing Tag | forbidden |
|---|---|
| CSS Display | inline |
DOM Information
Inheritance Hierarchy
Remarks
For a file upload to take place:
- The INPUT type=file element must be enclosed within a FORM element.
- A value must be specified for the NAME attribute of the INPUT type=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.
Examples
The following examples use the INPUT type=file element to upload a file to a server. The first example requires Microsoft Posting Acceptor, which can be used with IIS or Personal Web Server.
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="repost.asp" enctype="multipart/form-data" method="post"> <input type="file" name="oFile1"/> <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(Server.HTMLEncode(Request.Form("TargetURL"))) %></b>
</p>
<%
Response.write("<P>Name: " + Server.HTMLEncode(Request.Form("FileName")) + "</P>");
Response.write("<P>Size: " + Server.HTMLEncode(Request.Form("FileSize")) + "</P>");
Response.write("<P>Path: " + Server.HTMLEncode(Request.Form("FilePath")) + "</P>");
%>
</body>
</html>
See also
- input
- input
Build date: 3/8/2012
For IE8 Beta-1, we closed off the information-disclosure problem whereby JavaScript can read the .value attribute of a file upload control and determine the full local pathname, which might include information like the user’s name, profile directory, etc. Specifically, we changed from ALLOW to DENY for the Internet Zone “Include local directory path when uploading files” security setting. So, rather than sending the filename “C:\users\bill\desktop\temp\upload.txt”, we instead send just “upload.txt”.
..
Over the last few months, we’ve run into a significant number of sites (e.g. education products, several movie sharing sites, etc) and devices (e.g. popular home routers) that this security improvement breaks, because the sites use JavaScript to attempt to parse the filename (e.g. to determine its extension). In many cases, the script will attempt to get the indexOf() the last REVERSE_SOLIDUS (\) character in the string, and since we now return only the leaf filename, those scripts will fail to parse the string and complain to the user.
..
This was later modified, as a response to this problem, to display "C:\fakefile\filename.ext" instead of just the leaf filename.
Read more: http://blogs.msdn.com/ie/archive/2009/03/20/rtm-platform-changes.aspx
- 3/20/2009
- John Sudds [Microsoft]
- 2/13/2011
- LowLow Computers
When opening the "Choose file" Dialog box from a modeless popup...
1. the Dialog Box is then modeless (replaces the popup);
2. the Dialog box can disappear under its parent page (and is not in the Task bar);
3. the Dialog box interferes with--
-.a. contenteditable features act semi-rendered, cursor cannot sit between letters;
-.b. the parent page cannot X-close.
UNDER FURTHER TEST, for: z-level,...
PREMISE: Opening the Chooser Dialog box from a popup, facilitates an in-page Media Player Object to play audio files, e.g. voice notes while composing 'rich text' (contenteditable), e.g. when right-click/contextmenu cannot choose files, e.g. when Ctrl-O cannot open audio files as dependent windows to which the parent window page might thereby pass accelerator key actions ...
(N.B. RELATED: Use of such a popup itself, even without opening the chooser, can also cause contenteditable to belay action on its currently-selected element... REMEDY: Click on another element in the contenteditable.)
- 6/9/2009
- Mr. Raymond Kenneth Petry
- 6/9/2009
- Mr. Raymond Kenneth Petry
