php 文件和文件夹位于同一目录中,当我检查包含子文件夹和文件的路径时,它显示该文件不存在。但路径如果它存在于 Windows 资源管理器中。
<?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>";
}
}
?>
将路径中的双引号更改为单引号,但仍然无法检测到文件。
php应该如何构建路径来检测子文件夹和文件?