I do not understand very well why an input type file in a form does not work for me. Can you help me find the error?
Form :
<input type="file" name="imagen" class="form-control">
Processed :
<?php
$codigo = $_POST["codigo"];
if (is_uploaded_file ($_FILES['imagen']['tmp_name'])) {
$nombreDirectorio = "img/";
$nombreFichero = $codigo;
$nombreCompleto = $nombreDirectorio . $nombreFichero;
move_uploaded_file ($_FILES['imagen']['tmp_name'],
$nombreCompleto);
echo "Añadida con éxito";
} else {
echo "Error al subir imagen";
}
?>
I have also made Apache the owner of the files and folders of the web application so that it had all the permissions.