Compare commits
4 Commits
58e0f1eafd
...
main
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5ef5de9b98 | ||
![]() |
92e162283e | ||
![]() |
26fb9b54b6 | ||
![]() |
b4fcc4892c |
@@ -122,7 +122,7 @@ class NotesController
|
|||||||
$isAdmin = $_SESSION['role'] === 'admin';
|
$isAdmin = $_SESSION['role'] === 'admin';
|
||||||
$userid = $_SESSION['user_id'];
|
$userid = $_SESSION['user_id'];
|
||||||
|
|
||||||
$files = $this->notesModel->selectFiles($userid, true);
|
$files = $this->notesModel->selectFiles($userid, true, $sortBy, $sortOrder);
|
||||||
$this->view->setVars([
|
$this->view->setVars([
|
||||||
"files" => $files
|
"files" => $files
|
||||||
]);
|
]);
|
||||||
|
@@ -224,9 +224,13 @@ class NotesModel extends Database
|
|||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
if (!$pdo) return ['success' => false, 'message' => 'Database error.'];
|
if (!$pdo) return ['success' => false, 'message' => 'Database error.'];
|
||||||
|
|
||||||
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/EIANotesApp/Uploads/';
|
$uploadDir = __DIR__ . '/../Uploads/';
|
||||||
$uploadedFileNames = [];
|
$uploadedFileNames = [];
|
||||||
|
|
||||||
|
if (!file_exists($uploadDir)) {
|
||||||
|
mkdir($uploadDir, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_FILES['attachments']) && !empty($_FILES['attachments']['name'][0])) {
|
if (isset($_FILES['attachments']) && !empty($_FILES['attachments']['name'][0])) {
|
||||||
$files = $_FILES['attachments'];
|
$files = $_FILES['attachments'];
|
||||||
|
|
||||||
@@ -265,7 +269,7 @@ class NotesModel extends Database
|
|||||||
$stmt->execute([$fileId]);
|
$stmt->execute([$fileId]);
|
||||||
$file = $stmt->fetch();
|
$file = $stmt->fetch();
|
||||||
if ($file) {
|
if ($file) {
|
||||||
$filePath = $_SERVER['DOCUMENT_ROOT'] . '/EIANotesApp/Uploads/' . $file['stored_filename'];
|
$filePath = __DIR__ . '/../Uploads/' . $file['stored_filename'];
|
||||||
if (file_exists($filePath)) {
|
if (file_exists($filePath)) {
|
||||||
unlink($filePath);
|
unlink($filePath);
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@ include dirname(__DIR__).'/header.phtml';
|
|||||||
|
|
||||||
//// Test write permissions
|
//// Test write permissions
|
||||||
//// This is the directory we will upload files to.
|
//// This is the directory we will upload files to.
|
||||||
//$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/EIANotesApp/Uploads/';
|
//$uploadDir = __DIR__ . '/../Uploads/';
|
||||||
//if (!file_exists($uploadDir)) {
|
//if (!file_exists($uploadDir)) {
|
||||||
// mkdir($uploadDir, 0777, true);
|
// mkdir($uploadDir, 0777, true);
|
||||||
//}
|
//}
|
||||||
|
@@ -74,7 +74,7 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
|
|||||||
<ul>
|
<ul>
|
||||||
<?php foreach($files as $file): ?>
|
<?php foreach($files as $file): ?>
|
||||||
<li>
|
<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>
|
</li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
<?php foreach ($files as $file): ?>
|
<?php foreach ($files as $file): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo sanitize($file['id']); ?></td>
|
<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['stored_filename']); ?></td>
|
||||||
<td><?php echo sanitize($file['note_id']); ?></td>
|
<td><?php echo sanitize($file['note_id']); ?></td>
|
||||||
<td><?php echo sanitize($file['owner_username']); ?></td>
|
<td><?php echo sanitize($file['owner_username']); ?></td>
|
||||||
|
@@ -33,7 +33,7 @@ $files = $this->notesModel->getUploadedFiles($note['id']);
|
|||||||
<ul>
|
<ul>
|
||||||
<?php foreach ($files as $file): ?>
|
<?php foreach ($files as $file): ?>
|
||||||
<li>
|
<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>
|
</li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
Reference in New Issue
Block a user