// start multiple image
$stmt = $conn->prepare(“INSERT INTO cat_images (img_url, cat_id) VALUES (?, ?)”);
$stmt->bind_param(“si”, $imagePath, $cat_id);
$uploadedImages = $_FILES[‘images’];$cat_id = $conn->insert_id;
foreach ($uploadedImages[‘name’] as $key => $value) {
$targetDir = “main-images/galleries/”;
$fileName = basename($uploadedImages[‘name’][$key]);
$targetFilePath = $targetDir . $fileName;
if (file_exists($targetFilePath)) {
echo “Sorry, file already exists.<br>”;
} else {
if (move_uploaded_file($uploadedImages[“tmp_name”][$key], $targetFilePath)) {
$imagePath = $targetFilePath;
$stmt->execute();
echo “The file ” . $fileName . ” has been uploaded successfully.<br>”;
} else {
echo “Sorry, there was an error uploading your file.<br>”;
}
}
}
$stmt->close();
$conn->close();// end multiple image
Learn how to efficiently set up auto-increment columns in PostgreSQL with this step-by-step guide. From…
Just use below code and modified according to your need. Note: this is very useful…