New to our community ?

Discover a world of possibilities! Join us and explore a vibrant community where ideas flourish and connections thrive.

One of Our Valued Members

Thank you for being part of our community. Your presence enriches our shared experiences. Let's continue this journey together!

Home php codes Upload multiple images using PHP and MySQL.

Upload multiple images using PHP and MySQL.

Upload multiple images using PHP and MySQL.

Welcome back to . Today we will see how to upload more than 5 images in database with the help of php and mysql.

multiple image upload using php

so before start this tutorial let me clear the over all scenario of this post.we will create three PHP page here ,
in the very first step we establish our database connection .

in the second step we design a responsive form for uploading images and in the very last step
we will start to write code for uploading images in a specific folder and stores image name inside the database table.

upload multiple images using php


In this first step we write a code which are use for establishing a database connection.
we have our test_db database.
and the username and password are same root.

$db_con= mysqli_connect("localhost","root","root","test_db");


in this page we are design a html form which will use to take images from local system .

<!DOCTYPE html>
<form action="upload.php" method="post" enctype="multipart/form-data">
    <table width="100%">
            <td>Select Photo (one or multiple):</td>
            <td><input type="file" name="files[]" multiple/></td>
            <td colspan="2" align="center">Note: Supported image format: .jpeg, .jpg, .png, .gif</td>
            <td colspan="2" align="center"><input type="submit" value="Create Gallery" id="selectedButton"/></td>

In the upload.php page we will fetch images from local system and check the extensions of all images and store inside the storage folder.


<?php extract($_POST);
foreach($_FILES["files"]["tmp_name"] as $key=>$tmp_name) {

    if(in_array($ext,$extension)) {
        if(!file_exists("storage/".$txtGalleryName."/".$file_name)) {
        else {
    else {
        array_push($error,"$file_name, ");

Read More: Date calculatio