diff options
Diffstat (limited to 'files/pt-pt/web/api/file/getasbinary/index.html')
-rw-r--r-- | files/pt-pt/web/api/file/getasbinary/index.html | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/files/pt-pt/web/api/file/getasbinary/index.html b/files/pt-pt/web/api/file/getasbinary/index.html deleted file mode 100644 index 8ec42cf1f2..0000000000 --- a/files/pt-pt/web/api/file/getasbinary/index.html +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: File.getAsBinary() -slug: Web/API/File/getAsBinary -tags: - - API - - Ficheiros - - File API - - Non-standard - - Obsoleto - - Referencia - - metodo -translation_of: Web/API/File/getAsBinary ---- -<p>{{APIRef("File API")}}</p> - -<p>{{non-standard_header}}</p> - -<p>{{obsolete_header(7.0)}}</p> - -<h2 id="Sumário">Sumário</h2> - -<p>O método <code>getAsBinary</code> permite aceder aos dados de um ficheiro num formato <em>raw</em> binário.</p> - -<div class="note"> -<p><strong>Nota:</strong> Este método é obsoleto; use antes o método {{domxref("FileReader.readAsBinaryString()","readAsBinaryString()")}} ou {{domxref("FileReader.readAsArrayBuffer()","readAsArrayBuffer()")}} de {{domxref("FileReader")}}.</p> -</div> - -<h2 id="Sintaxe">Sintaxe</h2> - -<pre class="notranslate">var binary = <em>instanceOfFile</em>.getAsBinary();</pre> - -<h3 id="Retorna">Retorna</h3> - -<p>Uma <em>string</em>.</p> - -<h2 id="Exemplo">Exemplo</h2> - -<pre class="brush:js; notranslate">// fileInput é um HTMLInputElement: <input type="file" id="myfileinput" multiple> -var fileInput = document.getElementById("myfileinput"); - -// files é um objeto de FileList (parecido ao NodeList) -var files = fileInput.files; - -// objeto com os tipos de media permitidos -var accept = { - binary : ["image/png", "image/jpeg"], - text : ["text/plain", "text/css", "application/xml", "text/html"] -}; - -var file; - -for (var i = 0; i < files.length; i++) { - file = files[i]; - - // se o ficheiro pode ser detetado - if (file !== null) { - if (accept.binary.indexOf(file.type) > -1) { - // file contem dados binarios, num formato permitido - var data = file.getAsBinary(); - } else if (accept.text.indexOf(file.type) > -1) { - // file contem texto, num formato permitido - var data = file.getAsText(); - // modificar dados com métodos de string - } - } -}</pre> - -<h2 id="Specification" name="Specification">Especificação</h2> - -<p>Não pertence a nenhuma especificação.</p> - -<h2 id="Ver_também">Ver também</h2> - -<ul> - <li>{{domxref("File")}}</li> - <li>{{domxref("FileReader")}}</li> -</ul> |