Hi everyone,
how can i select an item from a directory and export the full name of it (for example test.txt) to an variable
the code on the dir list that i have is:
how can i select an item from a directory and export the full name of it (for example test.txt) to an variable
the code on the dir list that i have is:
Code:
<?php
$show_path = 1; # Show local path.
$show_dotdirs = 1; # Show '.' and '..'.
$path = substr($_SERVER['SCRIPT_FILENAME'], 0,
strrpos($_SERVER['SCRIPT_FILENAME'], '/') + 1);
?>
<html>
<head>
<title>DIR</title>
<style type="text/css">
body {
font-family: Verdana, Arial, sans-serif;
margin: 40px;
text-align: center;
}
body,
th,
td {
background-color: #ffffff;
}
a:link {
color: #666666;
text-decoration: underline;
}
a:visited {
color: #444444;
text-decoration: underline;
}
a:hover {
color: #666666;
text-decoration: none;
}
a:active {
color: #660000;
text-decoration: none;
}
table {
background-color: #222222;
border: #cccccc solid 1px;
border-spacing: 1px;
width: 480px;
}
th {
background-color: #4466aa;
color: #ffffff;
font-size: 11pt;
font-weight: bold;
text-align: left;
padding: 2px;
}
td {
background-color: #eeeeee;
color: #666666;
font-size: 9pt;
font-weight: normal;
padding: 6px;
}
</style>
</head>
<body>
<table cellspacing="1">
<tr>
<th><?php if ($show_path == 1) { echo $path; } else { echo 'content of this directory'; } ?></th>
</tr>
<tr>
<td>
<?php
$dirs = array();
$files = array();
$dir = dir($path);
while ($entry = $dir->read()) {
if (($entry != '.') and (substr($entry, -4) != '.php')) {
if (is_dir($entry)) {
if (($entry != '..') or $show_dotdirs){
$dirs[] = $entry;
}
} else {
$files[] = $entry;
}
}
}
$dir->close();
sort($dirs);
foreach ($dirs as $dir) {
printf('<strong><</strong> <a href="%s">%s</a> <strong>></strong><br />' . "\n", $dir, $dir);
}
sort($files);
foreach ($files as $file) {
printf('<a href="%s">%s<br />' . "\n", $file, $file);
}
?>
</td>
</tr>
</table>
<button type="button" onClick="window.location.href='../../main_login.php'";>Retroceder</button>
</body>
</html>
Comment