I have a problem that I do not know how to solve. I would like to know how I can check if an image has been sent through a form.
I have a form with different fields, one of them type of image
<form action="control.php" method="POST" enctype="multipart/form-data">
<!--Campos de tipo texto -->
<div class="form-group">
<label for="imagen">Imagen</label>
<input type="file" class="form-control-file" id="imagen" name="imagen" accept="image/*">
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" name="crearProducto">Crear</button>
</div>
</form>
In the control.php file I tried to check if an image was sent in the following ways
if(isset($_POST["imagen"])){
echo "Imagen enviada";
}else{
echo "imagen no enviada";
}
and
if(isset($_FILE["imagen"])){
echo "Imagen enviada";
}else{
echo "Imagen no enviada";
}
but in both cases the else is executed when I send the image, how can I do this check?