2
I’m in trouble with scandir
I can’t locate the directory at all, every time I get the following Warning
System cannot find specified path.
Check 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));
?>
Where is located "physically" the wpauditoria folder?
– Guilherme Nascimento
Inside the www folder in Wamp c:/wamp64/www/wpauditoria
– Diego Lela
And where your PHP script is located?
– Guilherme Nascimento
Did you mean the code ? In that folder ! It’s the localhost ..
– Diego Lela
Yes the PHP code you posted in the question, in which folder is it? Inside
wpauditoria
?– Guilherme Nascimento
Yes inside this folder ! But its subdivided is in this way wpaudit/panel-admin/include/galeriaimg/ the PHP script of the question
– Diego Lela
Okay, but I need to know where the php file is at least, regardless of subdivisions, unless you have multiple php files each in a folder that do the same thing.
– Guilherme Nascimento
You are on this path ... C:/wamp64/www/wpaudit/dashboard-admin/include/galeriaimg/gallery.php
– Diego Lela
Already the images that scandir should search is in this location c:/wamp64/wpaudit/images/library/medium/galeriaimg/gallery/
– Diego Lela
And by the browser you access php directly like this
http://localhost/wpauditoria/painel-admin/include/galeriaimg/galeria.php
or you make include in other . php?– Guilherme Nascimento
Just one detail, the port was missing so it would look like this localhost:3030/wpaudit/dashboard-admin/galeriaimg/gallery.php
– Diego Lela