diff options
Diffstat (limited to 'files/pt-br/web/api/filereader/onload/index.html')
-rw-r--r-- | files/pt-br/web/api/filereader/onload/index.html | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/files/pt-br/web/api/filereader/onload/index.html b/files/pt-br/web/api/filereader/onload/index.html new file mode 100644 index 0000000000..53b5774e88 --- /dev/null +++ b/files/pt-br/web/api/filereader/onload/index.html @@ -0,0 +1,29 @@ +--- +title: FileReader.onload +slug: Web/API/FileReader/onload +tags: + - Arquivo + - Event Handler + - FileReader + - Manipulador de eventos + - Propriedade +translation_of: Web/API/FileReader/onload +--- +<p>{{APIRef}}</p> + +<p>A propriedade <strong>FileReader.onload</strong> contém um manipulador de eventos (event handler) executado quando o evento de carregamento ({{event('load')}}) é ativado, quando o conteúdo lido com <a href="/en-US/docs/Web/API/FileReader/readAsArrayBuffer">readAsArrayBuffer</a>, <a href="/en-US/docs/Web/API/FileReader/readAsBinaryString">readAsBinaryString</a>, <a href="/en-US/docs/Web/API/FileReader/readAsDataURL">readAsDataURL</a> ou <a href="/en-US/docs/Web/API/FileReader/readAsText">readAsText</a> fica disponível.</p> + +<h2 id="Exemplo">Exemplo</h2> + +<pre class="brush:js; line-numbers language-js"><code class="language-js">// Callback de um <input type="file" onchange="onChange(event)"> +function onChange(event) { + var file = event.target.files[0]; + var reader = new FileReader(); + reader.onload = function(event) { + // O arquivo de texto será impresso aqui + console.log(event.target.result) + }; + + reader.readAsText(file); +} +</code></pre> |