因此,对于我的实习,我必须创建一个文件浏览器来查看远程服务器中的文件。我的问题是它没有显示子文件夹!但它确实显示了父文件夹。例如:它确实显示文件夹" Demo"但不是" Demo"中的子文件夹。就个人而言,我认为这是一个JS问题。这只发生在我使用远程服务器路径时。当文件夹位于服务器本地时,我的代码工作得很好。所以我的问题是:谁能看到我做错了什么?我无法找到问题:(
PHP:`
writeImageToBMP
JS: `
<?php
$dir = '\\\\zwosvr007\\SF Centraal\\Unica Online - Klant Portaal\\';
//$dir = 'handleidingen';
// $dir = 'handleidingen';
// Run the recursive function
$response = scan($dir);
// This function scans the files folder recursively, and builds a large array
function scan($dir)
{
$files = array();
// Is there actually such a folder/file?
foreach (glob($dir . "*", GLOB_BRACE) as $f) {
if (is_readable($f)) {
if (!$f || $f[0] == '.') {
continue; // Ignore hidden files
}
if (is_dir($f)) {
// The path is a folder
$files[] = array(
"name" => str_replace($dir, "", $f),
"type" => "folder",
"path" => $f,
"items" => scansub($f) // Recursively get the contents of the folder
);
} else {
// It is a file
$files[] = array(
"name" => str_replace($dir, "", $f),
"type" => "file",
"path" => $f,
//"size" => filesize($dir . '/' . $f) // Gets the size of this file
"size" => filesize($f) // Gets the size of this file
);
}
}
else{
// echo fileperms("\\\\zwoapp029\\DOSSIER\\");
// echo "<br>";
}
}
return $files;
}
function scansub($f){
$files = array();
foreach (scandir($f) as $g) {
if (!$g || $g[0] == '.') {
continue; // Ignore hidden files
}
if (is_dir($f . '\\' . $g)) {
// The path is a folder
$files[] = array(
"name" => $g,
"type" => "folder",
"path" => $f . '\\' . $g,
"items" => scansub($f . '\\' . $g) // Recursively get the contents of the folder
);
} else {
// It is a file
$files[] = array(
"name" => $g,
"type" => "file",
"path" => $f . '\\' . $g,
"size" => filesize($f. '\\' . $g) // Gets the size of this file
//"size" => filesize($f) // Gets the size of this file
);
}
}
return $files;
}
// Output the directory listing as JSON
header('Content-type: application/json');
echo json_encode(array(
"name" => $dir,
"type" => "folder",
"path" => $dir,
"items" => $response
));