-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_caption.php
More file actions
29 lines (23 loc) · 839 Bytes
/
Copy pathupdate_caption.php
File metadata and controls
29 lines (23 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
require 'db_connection.php'; // Ensure this includes your database connection
// Get JSON data from frontend
$data = json_decode(file_get_contents("php://input"), true);
if (isset($data["path"]) && isset($data["caption"])) {
$path = $data["path"];
$caption = $data["caption"];
$id = $data["id"];
// Update the caption in the database
$stmt = $db->prepare("UPDATE file_uploads SET caption = :caption WHERE id = :id");
$stmt->bindValue(':caption', $caption);
$stmt->bindValue(':id', $id);
$result = $stmt->execute();
if ($result) {
echo json_encode(["status" => "success"]);
} else {
echo json_encode(["status" => "error", "message" => "Failed to update."]);
}
$stmt->close();
} else {
echo json_encode(["status" => "error", "message" => "Invalid data."]);
}
?>