整理
This commit is contained in:
@@ -9,9 +9,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$maxRank = $Drama->q("SELECT MAX(`rank`) AS m FROM `dramas`");
|
||||
$nextRank = ((int)($maxRank[0]['m'] ?? 0)) + 1;
|
||||
|
||||
$posterName = '';
|
||||
if (!empty($_FILES['poster']['name']) && $_FILES['poster']['error'] === UPLOAD_ERR_OK) {
|
||||
$ext = strtolower(pathinfo($_FILES['poster']['name'], PATHINFO_EXTENSION));
|
||||
$posterName = uniqid('poster_') . '.' . $ext;
|
||||
move_uploaded_file($_FILES['poster']['tmp_name'], __DIR__ . '/../uploads/' . $posterName);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'title' => trim($_POST['title'] ?? ''),
|
||||
'type' => $type,
|
||||
'poster' => $posterName,
|
||||
'platform' => $_POST['platform'] ?? '其他',
|
||||
'watch_url' => trim($_POST['watch_url'] ?? ''),
|
||||
'current_season' => max(1, (int)($_POST['current_season'] ?? 1)),
|
||||
|
||||
@@ -11,6 +11,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$row['title'] = trim($_POST['title'] ?? $row['title']);
|
||||
$row['type'] = $_POST['type'] ?? $row['type'];
|
||||
$row['platform'] = $_POST['platform'] ?? $row['platform'];
|
||||
|
||||
if (!empty($_FILES['poster']['name']) && $_FILES['poster']['error'] === UPLOAD_ERR_OK) {
|
||||
$ext = strtolower(pathinfo($_FILES['poster']['name'], PATHINFO_EXTENSION));
|
||||
$row['poster'] = uniqid('poster_') . '.' . $ext;
|
||||
move_uploaded_file($_FILES['poster']['tmp_name'], __DIR__ . '/../uploads/' . $row['poster']);
|
||||
}
|
||||
$row['watch_url'] = trim($_POST['watch_url'] ?? '');
|
||||
$row['current_season'] = max(1, (int)($_POST['current_season'] ?? 1));
|
||||
$row['current_episode'] = max(0, (int)($_POST['current_episode'] ?? 0));
|
||||
@@ -29,7 +35,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<section>
|
||||
<h2 class="section-title">編輯作品</h2>
|
||||
|
||||
<form class="admin-form" method="post" action="?do=edit&id=<?= (int)$row['id'] ?>">
|
||||
<form class="admin-form" method="post" action="?do=edit&id=<?= (int)$row['id'] ?>" enctype="multipart/form-data">
|
||||
<label for="title">劇名/節目名</label>
|
||||
<input type="text" id="title" name="title" required
|
||||
value="<?= htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8') ?>">
|
||||
@@ -52,6 +58,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
<label for="poster">海報圖片</label>
|
||||
<?php if (!empty($row['poster'])): ?>
|
||||
<img src="../uploads/<?= htmlspecialchars($row['poster'], ENT_QUOTES, 'UTF-8') ?>" alt="" style="max-width:120px;display:block;margin-bottom:0.5rem;">
|
||||
<?php endif; ?>
|
||||
<input type="file" id="poster" name="poster" accept="image/*">
|
||||
|
||||
<label for="watch_url">直接觀看網址</label>
|
||||
<input type="url" id="watch_url" name="watch_url"
|
||||
value="<?= htmlspecialchars($row['watch_url'] ?? '', ENT_QUOTES, 'UTF-8') ?>"
|
||||
|
||||
Reference in New Issue
Block a user