Esempio n. 1
0
if (isset($_POST["doDelete"])) {
    $foldername = getFolderName();
    $filename = $foldername . '/' . fixFileName($_POST['file']);
    if (unlink($filename)) {
        $_SESSION['success'] = 'File deleted';
        header('Location: ' . addSession('index.php'));
    } else {
        $_SESSION['err'] = 'File delete failed';
        header('Location: ' . addSession('index.php'));
    }
    return;
}
// Switch to view / controller
$OUTPUT->header();
$OUTPUT->flashMessages();
echo '<h4 style="color:red">Are you sure you want to delete: ' . $fn . "</h4>\n";
?>
<form name=myform enctype="multipart/form-data" method="post">
    <input type=hidden name="file" value="<?php 
echo $_REQUEST['file'];
?>
">
<p><input type=submit name=doCancel onclick="location='<?php 
echo addSession('index.php');
?>
'; return false;" value="Cancel">
<input type=submit name=doDelete value="Delete"></p>
</form>
<?php 
Debug::log('Folder: ' . $foldername);
$OUTPUT->footer();
Esempio n. 2
0
Debug::log($foldername);
if (!file_exists($foldername)) {
    mkdir($foldername);
}
$finfo = finfo_open(FILEINFO_MIME_TYPE);
// return mime type ala mimetype extension
$count = 0;
foreach (glob($foldername . "/*") as $filename) {
    $fn = substr($filename, strlen($foldername) + 1);
    echo '<li><a href="files_serve.php?file=' . $fn . '" target="_new">' . $fn . '</a>';
    if ($USER->instructor) {
        echo ' (<a href="files_delete.php?file=' . $fn . '">Delete</a>)';
    }
    echo '</li>';
    $count = $count + 1;
    Debug::log($filename . " " . finfo_file($finfo, $filename));
}
if ($count == 0) {
    echo "<p>No Files Found</p>\n";
}
echo "</ul>\n";
finfo_close($finfo);
if ($USER->instructor) {
    ?>
<h4>Upload file (max <?php 
    echo maxUpload();
    ?>
MB)</h4>
<form name="myform" enctype="multipart/form-data" method="post" action="<?php 
    addSession('index.php');
    ?>