added upload to createNotes

This commit is contained in:
Felix Ivo
2025-07-07 10:21:15 +02:00
parent 871ffe01d0
commit 48f1fb8923
4 changed files with 86 additions and 7 deletions

View File

@@ -2,6 +2,16 @@
use ppa\Model\NotesModel;
include dirname(__DIR__).'/header.phtml';
// Test write permissions
// This is the directory we will upload files to.
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/EIANotesApp/Uploads/';
if (!file_exists($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
$testFile = $uploadDir . 'test_write.txt';
$testContent = 'Test write operation at ' . date('Y-m-d H:i:s');
$writeResult = file_put_contents($testFile, $testContent);
$parsedown = new Parsedown();
$parsedown->setSafeMode(true);
@@ -26,12 +36,16 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
<div class="page-header">
<h2>Create New Note</h2>
<a href="?controller=Notes&page=showNotes&do=showNotes" class="button secondary">Cancel</a>
<a href="?controller=Notes&page=showNotes&do=showNotes" class="button secondary">Cancel</a>
</div>
<label class="error-message"><?php if (isset($errmsg)):?>
<?php echo $errmsg;?>
<?php endif; ?></label>
<div id="drop-zone">Drag & drop a .txt or .md file here, or fill manually.</div>
<form id="note-form" method="POST">
<form id="note-form" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="create_note">
<div class="form-group">
<label for="title">Title:</label>
@@ -47,6 +61,13 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
Start typing or drop a file to see preview...
</div>
</div>
<div class="form-group">
<label for="attachments">Attach Files:</label>
<input type="file" id="attachments" name="attachments[]" multiple>
</div>
<div class="form-actions">
<button type="submit" class="button">Create Note</button>
</div>
@@ -54,4 +75,4 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
<input type="hidden" name="do" value="createNote">
</form>
</div>
</div>

View File

@@ -25,6 +25,10 @@
<a href="?controller=Notes&do=createNote" class="button">Create New Note</a>
</div>
<?php if (isset($errmsg)): ?>
<label class="error-message"><?php echo $errmsg; ?></label>
<?php endif; ?>
<table class="notes-table">
<thead>
<tr>