the php file and the folder are in the same directory, when I check the path that includes a subfolder and a file it shows that the file does not exist. but the path if it is in the windows explorer if it exists.
<?php
include('conexion.php');
if (!empty($_GET['copia']) ){
$consultar1 = mysqli_query($conexion,"SELECT * FROM documentos" );
$total = mysqli_num_rows($consultar1);
if($total > 0){
if (!file_exists("copia_seguridad")) {
mkdir("copia_seguridad",0777,true);
}
while ( $doct = mysqli_fetch_row($consultar1)){
$consultar_categoria = mysqli_query($conexion,"SELECT nombreCategoria FROM categorias");
$subdirectory = mysqli_fetch_array($consultar_categoria);
$longitud = count($subdirectory);
for($i=0; $i<$longitud; $i++){
$nombre_fichero = 'documentos/$subdirectory[$i]/".$doct[1].';
if (file_exists($nombre_fichero)) {
echo "El fichero $nombre_fichero existe";
} else {
echo "El fichero $nombre_fichero no existe";
}
}
}
echo "<script> alert('Copia de Seguridad realizada...'); </script>";
echo "<script>document.location.href = 'admin.php'; </script>";
}else{
echo "<script> alert('No hay documentos para guardar...'); </script>";
echo "<script>document.location.href = 'admin.php'; </script>";
}
}
?>
change the double quotes in the path to a single quote but it still doesn't detect the file.
How should the path be built for php to detect subfolders and files?