I have an input file in which I have limited to only accept file whose format is a text file, with extension .txt
.
I used the accept
attribute for this, see:
accept=".txt"
However, I would like to know if it is possible to check using jQuery, the format and the type of the file in case the accept
attribute fails?
Mcve
Example example:
function verificarArquivoTexto(arq)
{
}
$(
function ()
{
$('input:file').change(
function(e)
{
var arq = $(this).val().split('\').pop();
$('.arquivo').html(arq);
}
);
}
);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><inputid="upload" type="file" name="file-upload" accept=".txt">
<div class="arquivo">
</div>