I have a problem uploading some files through a form in PHP. The files are not uploaded. I have checked that the file name is correct, that it receives the temporary folder, and the final path, but nothing at all. The permissions of that folder are 777. I have also checked that the php.ini file is set to "file_uploads = On"
I've looked at different code examples and I can't find the error why my files won't upload to the server.
The fact is that the form processes it well, the name is generated perfectly for me because it saves it in the database... But I don't know why it doesn't upload the files to the server
I leave you the code of the html form:
<form class="row justify-content-center" enctype="multipart/form-data" action="procesar.php" method="post">
<div class="col-md-8">
<div class="form-1 row g-4">
<div class="col-12 col-lg-6">
<input type="text" class="form-control" name="nombre" placeholder="Nombre" required>
</div>
<div class="col-12 col-lg-6">
<input type="text" class="form-control" name="apellidos" placeholder="Apellidos" required>
</div>
<div class="col-12 col-lg-6">
<input type="number" class="form-control" name="telefono" placeholder="Teléfono" required>
</div>
<div class="col-12 col-lg-6">
<input type="email" class="form-control" name="email" placeholder="Email" required>
</div>
<div class="col-12 col-lg-6">
<input type="text" class="form-control" name="ciudad" placeholder="Ciudad" required>
</div>
<div class="col-12 col-lg-6">
<input type="text" class="form-control" name="tienda" placeholder="Nombre de la tienda" required>
</div>
</div>
</div>
<div class="col-md-8">
<div class="form-2 row">
<div class="col-12 col-lg-6">
<label for="Tiquet">Foto del tiquet</label>
<input type="file" class="form-control" name="tiquet" placeholder="tiquet" required>
</div>
<div class="col-12 col-lg-6">
<label for="Tiquet">Foto del material</label>
<input type="file" class="form-control" name="material" placeholder="material" required>
</div>
</div>
<div class="col-8 mt-3 btn-enviar text-center">
<button type="submit" class="btn btn-danger" name="enviar">Enviar formulario</button>
</div>
</div>
</form>
And this is the function that uploads the file to the server
public function subirImagenTiquet()
{
$directorio = "../uploads/";
$info = new SplFileInfo($_FILES["tiquet"]["name"]);
$nombre = strtolower($this->getNombre()) . "_tiquet_" . $this->getAleatorio() . "." . $info->getExtension();
$dirArchivoTemporal = $_FILES["tiquet"]["tmp_name"];
$dirArchivoFinal = $directorio . $nombre;
move_uploaded_file($dirArchivoTemporal, $dirArchivoFinal);
$this->setTiquet($dirArchivoFinal);
}
The var_dump($_FILES)
array(2) {
["tiquet"]=> array(5) { ["name"]=> string(16) "circle-black.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(14) "/tmp/phph41ROK" ["error"]=> int(0) ["size"]=> int(467) }
["material"]=> array(5) { ["name"]=> string(15) "circle-gray.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(14) "/tmp/phpRbIpqA" ["error"]=> int(0) ["size"]=> int(404) }
}
The var_dump result move_uploaded_file
bool(false) bool(false)
now
bool(false) Warning: move_uploaded_file(../uploads/jaimito_material_6431785209.jpg): failed to open stream: No such file or directory in /home/airlines/public_html/test/chino/includes/Form.php on line 69
Warning: move_uploaded_file(): Unable to move '/tmp/phpajTVlX' to '../uploads/jaimito_material_6431785209.jpg' in /home/airlines/public_html/test/chino/includes/Form.php on line 69