aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/api/file/getastext/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/de/web/api/file/getastext/index.html')
-rw-r--r--files/de/web/api/file/getastext/index.html78
1 files changed, 78 insertions, 0 deletions
diff --git a/files/de/web/api/file/getastext/index.html b/files/de/web/api/file/getastext/index.html
new file mode 100644
index 0000000000..fefda6647a
--- /dev/null
+++ b/files/de/web/api/file/getastext/index.html
@@ -0,0 +1,78 @@
+---
+title: File.getAsText()
+slug: Web/API/File/getAsText
+tags:
+ - DOM
+ - Files
+translation_of: Web/API/File/getAsText
+---
+<p>{{APIRef("File API") }}{{non-standard_header}}</p>
+
+<p>{{deprecated_header(7.0)}}</p>
+
+<h2 id="Summary">Summary</h2>
+
+<p>The <code>getAsText</code> method provides the file's data interpreted as text using a given encoding.</p>
+
+<div class="note">
+<p><strong>Note:</strong> This method is obsolete; you should use the {{domxref("FileReader")}} method {{domxref("FileReader.readAsText()","readAsText()")}} instead.</p>
+</div>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<pre>var str = instanceOfFile.getAsText(encoding);</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt>encoding</dt>
+ <dd>A string indicating the encoding to use for the returned data. If this string is empty, UTF-8 is assumed.</dd>
+</dl>
+
+<h3 id="Returns">Returns</h3>
+
+<p>A string containing the file's data interpreted as text in the specified <code>encoding</code>.</p>
+
+<h2 id="Example">Example</h2>
+
+<pre class="brush: js">// fileInput is a HTMLInputElement: <input>
+var fileInput = document.getElementById("myfileinput");
+
+// files is a FileList object (similar to NodeList)
+var files = fileInput.files;
+
+// object for allowed media types
+var accept = {
+ binary : ["image/png", "image/jpeg"],
+ text : ["text/plain", "text/css", "application/xml", "text/html"]
+};
+
+var file;
+
+for (var i = 0; i &lt; files.length; i++) {
+ file = files[i];
+
+ // if file type could be detected
+ if (file !== null) {
+ if (accept.text.indexOf(file.mediaType) &gt; -1) {
+ // file is of type text, which we accept
+ // make sure it's encoded as utf-8
+ var data = file.getAsText("utf-8");
+ // modify data with string methods
+
+ } else if (accept.binary.indexOf(file.mediaType) &gt; -1) {
+ // binary
+ }
+ }
+}</pre>
+
+<h2 id="Specification">Specification</h2>
+
+<p>Not part of any specification.</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{domxref("File")}}</li>
+ <li>{{domxref("FileReader")}}</li>
+</ul>