nsIDOMFileList

  • Revision slug: nsIDOMFileList
  • Revision title: nsIDOMFileList
  • Revision id: 127291
  • Created:
  • Creator: Kohei
  • Is current revision? No
  • Comment /* In other languages */

Revision Content

{{template.Fx_minversion_header(3)}} The nsIDOMFileList interface contains a list of {{template.Interface("nsIDOMFile")}} objects describing the files selected by the user for a "file" input field on a web form.

All <INPUT> element nodes have a fileList array on them which allows access to the items in this list. For example, if the HTML includes the following file input:

<input id="fileItem" type=file>

The following lines of code each fetch the first file in the node's file list in different formats:

// Get the file's data in UTF-8 (the default text encoding)
document.getElementById('fileItem').fileList[0].getAsText("");

// Get the file's data interpreted as UTF-8 specifically
document.getElementById('fileItem').fileList[0].getAsText("utf8")

// Get the file's data as a data: URL
document.getElementById('fileItem').fileList[0].getAsDataURL()

// Get the file's data as raw binary data
document.getElementById('fileItem').fileList[0].getAsBinary()


{{template.InterfaceStatus("nsIDOMFileList", "content/base/public/nsIDOMFileList.idl", "unfrozen", "Mozilla 1.9", "yes")}}

Inherits from: {{template.Interface("nsISupports")}}

Method overview

nsIDOMFile item(in unsigned long index);

Attributes

Attribute Type Description
length unsigned long A read-only attribute indicating the number of files in the list.

Methods

item()

Returns the {{template.Interface("nsIDOMFile")}} at the specified index in the file list.

 nsIDOMFile item(
   in unsigned long index
 );
Parameters
<tt>index</tt>
The zero-based index of the file to retrieve from the list.
Return value

The {{template.Interface("nsIDOMFile")}} representing the requested file.

See also

{{template.Interface("nsIDOMFile")}}, {{template.Interface("nsIDOMFileException")}}

{{ wiki.languages( { "ja": "ja/NsIDOMFileList" } ) }}

Revision Source

<p>
{{template.Fx_minversion_header(3)}}
The <code>nsIDOMFileList</code> interface contains a list of {{template.Interface("nsIDOMFile")}} objects describing the files selected by the user for a "file" input field on a web form.
</p><p>All <code>&lt;INPUT&gt;</code> element nodes have a <code>fileList</code> array on them which allows access to the items in this list.  For example, if the HTML includes the following file input:
</p>
<pre class="eval">&lt;input id="fileItem" type=file&gt;
</pre>
<p>The following lines of code each fetch the first file in the node's file list in different formats:
</p>
<pre class="eval">// Get the file's data in UTF-8 (the default text encoding)
document.getElementById('fileItem').fileList[0].getAsText("");

// Get the file's data interpreted as UTF-8 specifically
document.getElementById('fileItem').fileList[0].getAsText("utf8")

// Get the file's data as a data: URL
document.getElementById('fileItem').fileList[0].getAsDataURL()

// Get the file's data as raw binary data
document.getElementById('fileItem').fileList[0].getAsBinary()
</pre>
<p><br>
{{template.InterfaceStatus("nsIDOMFileList", "content/base/public/nsIDOMFileList.idl", "unfrozen", "Mozilla 1.9", "yes")}}
</p><p>Inherits from: {{template.Interface("nsISupports")}}
</p>
<h2 name="Method_overview">Method overview</h2>
<table class="standard-table">

<tbody><tr>
<td> <code>nsIDOMFile <a href="#item.28.29">item</a>(in unsigned long index);</code>
</td></tr>
</tbody></table>
<h2 name="Attributes">Attributes</h2>
<table class="standard-table">

<tbody><tr>
<td class="header">Attribute
</td><td class="header">Type
</td><td class="header">Description
</td></tr>

<tr>
<td><code>length</code>
</td><td><code>unsigned long</code>
</td><td> A read-only attribute indicating the number of files in the list.
</td></tr>
</tbody></table>
<h2 name="Methods">Methods</h2>
<h3 name="item.28.29">item()</h3>
<p>Returns the {{template.Interface("nsIDOMFile")}} at the specified index in the file list.
</p>
<pre class="eval"> nsIDOMFile item(
   in unsigned long index
 );
</pre>
<h6 name="Parameters">Parameters</h6>
<dl><dt><tt>index</tt>
</dt><dd>The zero-based index of the file to retrieve from the list.
</dd></dl>
<h6 name="Return_value">Return value</h6>
<p>The {{template.Interface("nsIDOMFile")}} representing the requested file.
</p>
<h2 name="See_also">See also</h2>
<p>{{template.Interface("nsIDOMFile")}}, {{template.Interface("nsIDOMFileException")}}
</p>{{ wiki.languages( { "ja": "ja/NsIDOMFileList" } ) }}
Revert to this revision