fill title with filename when uploading
This commit is contained in:
parent
d7b9df6733
commit
7d12954372
1 changed files with 12 additions and 2 deletions
|
@ -1,7 +1,8 @@
|
||||||
<div class="text document edit-form">
|
<div class="text document edit-form">
|
||||||
<form method="post" id="form" action="admin.php?action=edit_item<?= empty($doc) ? "" : "&item=" . $doc["ID"] ?>"
|
<form method="post" id="form" action="admin.php?action=edit_item<?= empty($doc) ? "" : "&item=" . $doc["ID"] ?>"
|
||||||
enctype="multipart/form-data">
|
enctype="multipart/form-data">
|
||||||
<strong>Title:</strong> <input type="text" name="Title" value="<?= empty($doc) ? "" : $doc["Title"] ?>"><br>
|
<strong>Title:</strong> <input id="title-input" type="text" name="Title"
|
||||||
|
value="<?= empty($doc) ? "" : $doc["Title"] ?>"><br>
|
||||||
<strong>Author:</strong> <input type="text" name="Author" value="<?= empty($doc) ? "" : $doc["Author"] ?>"><br>
|
<strong>Author:</strong> <input type="text" name="Author" value="<?= empty($doc) ? "" : $doc["Author"] ?>"><br>
|
||||||
<strong>Date published:</strong> <input type="text" name="Published"
|
<strong>Date published:</strong> <input type="text" name="Published"
|
||||||
value="<?= empty($doc) ? "" : $doc["Published"] ?>"><br>
|
value="<?= empty($doc) ? "" : $doc["Published"] ?>"><br>
|
||||||
|
@ -9,7 +10,7 @@
|
||||||
<textarea name="Description" cols="120" rows="20">
|
<textarea name="Description" cols="120" rows="20">
|
||||||
<?= empty($doc) ? "" : $doc["Description"] ?>
|
<?= empty($doc) ? "" : $doc["Description"] ?>
|
||||||
</textarea><br>
|
</textarea><br>
|
||||||
<strong>File:</strong> <input type="file" name="upfile"><br>
|
<strong>File:</strong> <input id="file-input" type="file" name="upfile" onchange="updateTitle()"><br>
|
||||||
<strong>URL:</strong> <input type="text" name="URL" value="<?= empty($doc) ? "" : $doc["URL"] ?>"><br>
|
<strong>URL:</strong> <input type="text" name="URL" value="<?= empty($doc) ? "" : $doc["URL"] ?>"><br>
|
||||||
<strong>Tags:</strong> <input type="text" name="Tags" value="<?php
|
<strong>Tags:</strong> <input type="text" name="Tags" value="<?php
|
||||||
if (!empty($doc)) {
|
if (!empty($doc)) {
|
||||||
|
@ -25,3 +26,12 @@
|
||||||
<input type="submit">
|
<input type="submit">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
function updateTitle() {
|
||||||
|
const titleInput = document.getElementById("title-input");
|
||||||
|
if (titleInput.value.length === 0) {
|
||||||
|
const filename = document.getElementById("file-input").value;
|
||||||
|
titleInput.value = filename.replace(/.*[\/\\]/, '').replace(/\.[\w]{2,}$/, '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue