Mam pewnien problem w jednym skrypcie mam przekazanie zmiennej poprzez <a href="managerplikow.php?katalog=pliki/moje/">Pliki</a> do skryptu zarządzającego plikami ( download, upload, delete). I niby wszystko jest OK, otwiera strone z katalogiem przekazanym w zmiennej ale niestety, nie dzial upload, download ani delete, zmiennia znika ze skryptu. Ponizej skrypt do zarzadzania plikami. Prosze o pomoc
CODE
<?php
$readpath = "$katalog";
$hide = array( 'resources',
'index.php',
'.htaccess',
'.htpasswd',
'.DS_Store');
error_reporting(E_ALL);
if ($_GET['download']) {
$file = str_replace('/', '', $_GET['download']);
$file = str_replace('..', '', $file);
$file = $readpath.$file;
if (file_exists($file)) {
header("Content-type: application/x-download");
header("Content-Length: ".filesize($file));
header('Content-Disposition: attachment; filename="'.$file.'"');
readfile($file);
die();
}
}
$handle = opendir($readpath);
// If deleting
if (isset($_GET['rmfile'])) {
unlink($readpath . $_GET['rmfile']);
}
// If uploading
if ($_FILES['file']) {
$success = move_uploaded_file($_FILES['file']['tmp_name'], $readpath. $_FILES['file']['name']);
}
$key=0;
while ($file = readdir($handle)) {
if ($file == "." || $file == ".." || in_array($file, $hide)) continue;
$key++;
$files[$key] = $file;
}
closedir($handle);
// ksort($files, SORT_NUMERIC);
$files = array_reverse($files);
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table border="0" cellspacing="5" cellpadding="5">
<?php
for ($i=0; $i<count($files); $i++) {
$filename = $files[$i];
?>
<tr>
<td><img src="resources/zip.gif"></td>
<td><a href="managerplikow.php?download=<?php echo $filename; ?>"><?php echo $filename; ?></a></td>
<td><a href="managerplikow.php?rmfile=<?php echo $filename; ?>">Delete</a></td>
</tr>
<?php } ?>
</table>
<div id="upload">
<form method="post" action="managerplikow.php" enctype="multipart/form-data">
<p><input type="file" name="file"></p>
<p><input type="submit" value="Upload"></p>
</form>
</div>
</body>
</html>
$readpath = "$katalog";
$hide = array( 'resources',
'index.php',
'.htaccess',
'.htpasswd',
'.DS_Store');
error_reporting(E_ALL);
if ($_GET['download']) {
$file = str_replace('/', '', $_GET['download']);
$file = str_replace('..', '', $file);
$file = $readpath.$file;
if (file_exists($file)) {
header("Content-type: application/x-download");
header("Content-Length: ".filesize($file));
header('Content-Disposition: attachment; filename="'.$file.'"');
readfile($file);
die();
}
}
$handle = opendir($readpath);
// If deleting
if (isset($_GET['rmfile'])) {
unlink($readpath . $_GET['rmfile']);
}
// If uploading
if ($_FILES['file']) {
$success = move_uploaded_file($_FILES['file']['tmp_name'], $readpath. $_FILES['file']['name']);
}
$key=0;
while ($file = readdir($handle)) {
if ($file == "." || $file == ".." || in_array($file, $hide)) continue;
$key++;
$files[$key] = $file;
}
closedir($handle);
// ksort($files, SORT_NUMERIC);
$files = array_reverse($files);
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table border="0" cellspacing="5" cellpadding="5">
<?php
for ($i=0; $i<count($files); $i++) {
$filename = $files[$i];
?>
<tr>
<td><img src="resources/zip.gif"></td>
<td><a href="managerplikow.php?download=<?php echo $filename; ?>"><?php echo $filename; ?></a></td>
<td><a href="managerplikow.php?rmfile=<?php echo $filename; ?>">Delete</a></td>
</tr>
<?php } ?>
</table>
<div id="upload">
<form method="post" action="managerplikow.php" enctype="multipart/form-data">
<p><input type="file" name="file"></p>
<p><input type="submit" value="Upload"></p>
</form>
</div>
</body>
</html>