0
Good afternoon, I need a code that simulates the submission of an input file that when selected some value, it submits to 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 receive 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 commit it, but as soon as the input selects a value it submits in the same way as the code above.
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
}
});
});
https://answall.com/a/269912/99718
– Valdeir Psr
Possible duplicate of Recover Input File to Pass as Date in AJAX
– PauloHDSousa