Image upload form not posting input value when auto submitting form
-
28-10-2019 - |
Pergunta
I am trying to create an avatar uploader, but I want to be able to click only one button that opens the browsing window and then automatically calls the upload method from the AvatarUpload
class.
The problem I have identified is that the form doesn't seem to be posting anything.
Any help would be great!
var_dump(isset($_POST['uploaded']));
if( isset($_POST['uploaded']) )
{
$img = new AvatarUpload();
$img->startUpload();
}
else
{
?>
<form method="post" enctype="multipart/form-data" name="uploadAvatar">
<p>
<input type="file" name="uploaded" id="file" onchange="this.form.submit()" />
<p>
</form>
<?php
}
?>
Solução
when you upload files they are listed under the $_FILES, not $_POST.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow