Почему, нажав на ссылку, не происходит отображение содержания уже другой директории? Код (Text): <?php echo '<form method="POST">'; $dir = $_SERVER['DOCUMENT_ROOT']; echo '<input type="text" name="location" value="'.$dir.'"><input type="submit" value="Перейти"><br>'; if (isset($_POST["location"])) { $dir = $_POST['location']; } if (is_dir($dir)) { if ($dh = opendir($dir)) { while (false !== ($file = readdir($dh))) { echo '<a href="?act=fm&file='.$file.'">'.$file.'</a><br>'; if (isset($_GET['file'])) { if (is_dir($dir.'/'.$_GET['file'])) { $dir = $_POST['location'].'/'.$_GET['file']; $msg = 'Directory changed'; } if (is_file($dir.'/'.$_GET['file'])) { $msg = 'File could not be opened!'; } } } closedir($dh); } } echo '</form>'; echo $msg; ?>
Код (Text): <?php $path = realpath('.'); $dir = ''; if (isset($_GET['dir'])) { $dir = $_GET['dir'] . DIRECTORY_SEPARATOR; } if (isset($_GET['file'])) { $filePath = $_GET['file']; $file = new SplFileObject($filePath); var_dump($file); } $path = realpath($path . DIRECTORY_SEPARATOR . $dir); $allowedExtensions = array( 'php', 'png' ); $excludeDirectories = array( '.git' ); $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CATCH_GET_CHILD); foreach ($objects as $name => $object) { if ($object->isDir() && !in_array($object->getFilename(), $excludeDirectories)) { echo '<a href="?dir=' . $dir . $object->getFilename() . '">' . $object->getFilename() . '</a><br/>'; } else { if (in_array($object->getExtension(), $allowedExtensions)) { echo '<a href="?file=' . $dir . $object->getFilename() . '">' . $object->getFilename() . '</a><br/>'; } } } поробуйте етот