Compare commits

..

4 Commits

Author SHA1 Message Date
Felix Ivo
5ef5de9b98 fixed document upload location 2025-07-08 10:51:57 +02:00
Felix Ivo
92e162283e fixed directory location 2025-07-07 15:08:56 +02:00
Felix Ivo
26fb9b54b6 fixed upoad folder missing 2025-07-07 14:52:46 +02:00
Felix Ivo
b4fcc4892c fixed sorting 2025-07-07 14:50:48 +02:00
6 changed files with 12 additions and 8 deletions

View File

@@ -122,7 +122,7 @@ class NotesController
$isAdmin = $_SESSION['role'] === 'admin';
$userid = $_SESSION['user_id'];
$files = $this->notesModel->selectFiles($userid, true);
$files = $this->notesModel->selectFiles($userid, true, $sortBy, $sortOrder);
$this->view->setVars([
"files" => $files
]);

View File

@@ -224,8 +224,12 @@ class NotesModel extends Database
$pdo = $this->linkDB();
if (!$pdo) return ['success' => false, 'message' => 'Database error.'];
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/EIANotesApp/Uploads/';
$uploadDir = __DIR__ . '/../Uploads/';
$uploadedFileNames = [];
if (!file_exists($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
if (isset($_FILES['attachments']) && !empty($_FILES['attachments']['name'][0])) {
$files = $_FILES['attachments'];
@@ -265,7 +269,7 @@ class NotesModel extends Database
$stmt->execute([$fileId]);
$file = $stmt->fetch();
if ($file) {
$filePath = $_SERVER['DOCUMENT_ROOT'] . '/EIANotesApp/Uploads/' . $file['stored_filename'];
$filePath = __DIR__ . '/../Uploads/' . $file['stored_filename'];
if (file_exists($filePath)) {
unlink($filePath);
}

View File

@@ -4,7 +4,7 @@ include dirname(__DIR__).'/header.phtml';
//// Test write permissions
//// This is the directory we will upload files to.
//$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/EIANotesApp/Uploads/';
//$uploadDir = __DIR__ . '/../Uploads/';
//if (!file_exists($uploadDir)) {
// mkdir($uploadDir, 0777, true);
//}

View File

@@ -74,7 +74,7 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
<ul>
<?php foreach($files as $file): ?>
<li>
<a href="/EIANotesApp/Uploads/<?php echo $file['stored_filename']; ?>" download target="_blank"><?php echo htmlspecialchars($file['original_filename']); ?></a>
<a href="<?php echo substr($_SERVER['PHP_SELF'], 0, -9).'Uploads/'.$file['stored_filename']; ?>" download target="_blank"><?php echo htmlspecialchars($file['original_filename']); ?></a>
</li>
<?php endforeach; ?>
</ul>

View File

@@ -24,7 +24,7 @@
<?php if (isset($errmsg)): ?>
<label class="error-message"><?php echo $errmsg; ?></label>
<?php endif; ?>
<table class="notes-table">
<thead>
<tr>
@@ -42,7 +42,7 @@
<?php foreach ($files as $file): ?>
<tr>
<td><?php echo sanitize($file['id']); ?></td>
<td><a href="/EIANotesApp/Uploads/<?php echo $file['stored_filename']; ?>" download target="_blank"><?php echo sanitize($file['original_filename']); ?></a></td>
<td><a href="<?php echo substr($_SERVER['PHP_SELF'], 0, -9).'Uploads/'.$file['stored_filename']; ?>"><?php echo sanitize($file['stored_filename']); ?></a></td>
<td><?php echo sanitize($file['stored_filename']); ?></td>
<td><?php echo sanitize($file['note_id']); ?></td>
<td><?php echo sanitize($file['owner_username']); ?></td>

View File

@@ -33,7 +33,7 @@ $files = $this->notesModel->getUploadedFiles($note['id']);
<ul>
<?php foreach ($files as $file): ?>
<li>
<a href="/EIANotesApp/Uploads/<?php echo $file['stored_filename']; ?>" download target="_blank"><?php echo htmlspecialchars($file['original_filename']); ?></a>
<a href="<?php echo substr($_SERVER['PHP_SELF'], 0, -9).'Uploads/'.$file['stored_filename']; ?>" download target="_blank"><?php echo htmlspecialchars($file['original_filename']); ?></a>
</li>
<?php endforeach; ?>
</ul>