I am trying to upload multiple images with a caption, a caption where the user can edit and update the caption.
I have no problem uploading multiple images, but I couldn’t figure out how to add a caption for each uploaded image with the edit/update option.
Image index page for upload form
Multiple Image Upload Code
$sernamename = "localhost";
$username = "root";
$passoword = "";
$databasename= "my_db";
// Create database connection
$con = mysqli_connect($sernamename, $username,$passoword,$databasename);
// Check connection
if ($con->connect_error) {
die("Connection failed". $con->connect_error);
}
// Upload multiple image in Database using PHP MYSQL
if (!empty($_FILES['multipleFile']['name'])) {
$multiplefile = $_FILES['multipleFile']['name'];
foreach ($multiplefile as $name => $value) {
$allowImg = array('png','jpeg','jpg','');
$fileExnt = explode('.', $multiplefile[$name]);
if (in_array($fileExnt[1], $allowImg)) {
if ($_FILES['multipleFile']['size'][$name] > 0 && $_FILES['multipleFile']['error'][$name]== 0) {
$fileTmp = $_FILES['multipleFile']['tmp_name'][$name];
$newFile = rand(). '.'. $fileExnt[1];
$target_dir="uploads/".$newFile;
if (move_uploaded_file($fileTmp, $target_dir)) {
$query = "INSERT INTO table_images (images) VALUES('$newFile')";
mysqli_query($con, $query);
}
}
}
}
}
Retrieve data to display submitted image from database
$query = "SELECT * FROM table_images";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$images = $row['images'];
?>
;
No Image found";
}
The image can be uploaded and displayed easily, but how can I add a caption for images that the user can edit/update.
how can i get this caption option with multiple image upload options where user can edit caption and update it