Good afternoon, I need a code that simulates the submission of an input file file that when selected some value, it submits to the php in the same way as if it were submitting in an html form. For example
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="arquivo">
</form>
And in php, it would get this way ...
<?php
//Exemplo de como receberia o valor do input
$arquivo = $_FILES['arquivo'];
?>
What I need is that in jquery I can do this, without needing an html form and a button to submit it, but as soon as the input selects a value it submits the same as the above code.
The code I already have is this ...
HTML
<input type="file" name="am" id = 'am' accept='.pdf'>
JQUERY
$(document).ready(function(){
// Quando valor for alterado no input
$("#am").change(function(){
// Se o valor alterado do input for diferente de nada
if($("#am").val()!=""){
// Aqui deve ficar o código para submeter para o php
}
});
});