Skip to content
Snippets Groups Projects
Commit ba5566ec authored by ZHANG David's avatar ZHANG David
Browse files

Upload New File

parent 0ee61b98
No related branches found
No related tags found
No related merge requests found
<?php
include 'config.php';
session_start();
if (!isset($_SESSION['user']) || $_SESSION['user']['role'] !== 'tutor') {
echo "<div class='container'><p class='error'>Access denied. Only tutors can view files.</p><a href='login.php'>Go back</a></div>";
exit;
}
$user = $_SESSION['user'];
$tutor_id = intval($user['id']); // Récupération de l'ID du professeur connecté
// Récupérer uniquement les dépôts créés par ce professeur
$depots = $conn->query("SELECT * FROM depots WHERE tutor_id = $tutor_id");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>View Files</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php include 'sidebar.php'; ?>
<div class="main-content">
<div class="attendance-page">
<h1>View Files</h1>
<?php if ($depots->num_rows > 0): ?>
<?php while ($depot = $depots->fetch_assoc()): ?>
<h2><?= htmlspecialchars($depot['nom']) ?></h2>
<p><?= htmlspecialchars($depot['description']) ?></p>
<ul>
<?php
$depot_id = intval($depot['id']);
$files = $conn->query("SELECT * FROM fichiers WHERE depot_id = $depot_id");
if ($files->num_rows > 0):
?>
<table border="1" cellpadding="10">
<thead>
<tr>
<th>File Name</th>
<th>Sender</th>
<th>Upload Date</th>
<th>Download</th>
</tr>
</thead>
<tbody>
<?php while ($file = $files->fetch_assoc()): ?>
<tr>
<td><?= htmlspecialchars($file['nom_fichier']) ?></td>
<td><?= htmlspecialchars($file['expediteur']) ?></td>
<td><?= date('d-m-Y H:i', strtotime($file['date_upload'])) ?></td>
<td>
<a href="<?= htmlspecialchars($file['path_fichier']) ?>" download>
Download
</a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<?php else: ?>
<p>Pas de fichiers téléversés encore</p>
<?php endif; ?>
</ul>
<?php endwhile; ?>
<?php else: ?>
<p>No depots found.</p>
<?php endif; ?>
</div>
</div>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment