PHP - Scandir does not work [closed]

2

I'm having problems with scandir I can not find the directory in any way, every time I get the following Warning

  

The system can not find the path specified.

Look at my code. I use Wamp X64, Windows 10 and PHP 5.6:

<?php

  $pasta = filter_input(INPUT_GET, 'pasta');          
  $tamanho = filter_input(INPUT_GET, 'tamanho');    

   /* separador */
  $separador = '/galeriaimg/';

  // aqui recebo somente o valor que preciso ou seja o nome da pasta
  $valor  = explode($separador, $pasta);

  // repassando somente o valor necessário para a variavel
  $pasta = $valor[1];

  // Formas que eu tentei obter o retorno do Scandir todas sem sucesso!
  $dir = 'http://localhost:3030/wpauditoria/images/biblioteca/$tamanho/galeriaimg/$pasta';
  $dir = $_SERVER['DOCUMENT_ROOT']."/wpauditoria/images/biblioteca/$tamanho/galeriaimg/$pasta";
  $dir = "../../../images/biblioteca/$tamanho/galeriaimg/$pasta";
  $dir = "/wpauditoria/images/biblioteca/$tamanho/galeriaimg/$pasta";

   $files = scandir($dir);

  //echo (json_encode($files));

 ?>
    
asked by anonymous 25.08.2017 / 03:34

1 answer

1

I discovered the problem.

I'm using the responsivefilemanager plugin to select the files and this plugin has an option to create images in pre-defined size folders etc., these settings can be set in the plugin's (config.php).

So when the image is too small, it does not create the stipulated folder to resize in the "medium" directory (it was within that directory that I customized the resized images) and this caused the error because the path where it actually searched there was, after all I uploaded a very small image that was not necessary to resize ..

Another important detail is how to search with scandir. It worked only here when I called $_SERVER['DOCUMENT_ROOT'] before the place where the script is.

In this way:

$dir = $_SERVER['DOCUMENT_ROOT']."/wpauditoria/images/biblioteca/medium/galeriaimg/galeria;
    
25.08.2017 / 14:43