Add document upload to Redact tool

api/extract.php — new endpoint accepting .pdf/.docx/.txt up to 4 MB;
pdftotext for PDFs, ZipArchive+DOMXPath for DOCX, mb_convert_encoding
for TXT; truncates to 32 000 chars to stay within redact limit.

index.php — drop/browse upload zone above the textarea, visible only
in Redact mode.

tools.js — setupUpload(), handleFileUpload(), resetUpload(); drag-and-drop
and file picker both call the extract endpoint then populate the textarea.

tools.css — upload zone, drag-over, file-info, clear button styles.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-13 06:52:14 +02:00
parent 3c8d7ebc34
commit bbe5307c03
4 changed files with 335 additions and 0 deletions
+13
View File
@@ -218,6 +218,19 @@ $authenticated = dbnToolsIsAuthenticated();
<label><input type="radio" name="redactionRegion" value="global"> Global</label>
</div>
<div class="upload-zone is-hidden" id="uploadZone" role="region" aria-label="File upload">
<input type="file" id="uploadInput" accept=".pdf,.docx,.txt" aria-label="Choose a file">
<div id="uploadPrompt" class="upload-prompt">
<span class="upload-icon" aria-hidden="true">&#8679;</span>
<p>Drop a <strong>.pdf</strong>, <strong>.docx</strong>, or <strong>.txt</strong>, or <label for="uploadInput" class="upload-browse">browse</label></p>
<p class="upload-hint">Text is extracted and never stored.</p>
</div>
<div id="uploadFileInfo" class="upload-file is-hidden">
<span id="uploadFileName" class="upload-filename"></span>
<button type="button" id="uploadClear" class="upload-clear" aria-label="Clear uploaded file">&times;</button>
</div>
</div>
<label class="input-label" for="toolInput" id="inputLabel">Question</label>
<textarea id="toolInput" name="toolInput" rows="10" required></textarea>