drag and drop multiple image upload
Posted in: Jquery, PHP

Upload Multiple Images Using PHP | Drag and Drop Image Upload

Uploading multiple images using php is the main thing  to achieve with this tutorial. In this article i will show you that how you can upload multiple images using Jquery Drag and Drop Feature. We will also save the uploaded values to the database so that you can use it further.

I have already written a tutorial regarding uploading images to database using PHP. If you want t upload one by one images you can use the previous tutorial.

For uploading the Multiple images we have 2 methods One is simple input file tag to upload the image other one is very easy and user friendly Drag and Drop Image upload. In this tutorial i will show you how you can use the Drag and Drop Method.

Thing’s We need.

  • Database
  • Jquery Plugin
  • HTML upload form
  • PHP Upload Class
  • List Images HTML Page
  • Connection Class

We will start with creating table in our database. In our database table  we will save only the name of the image file so we can use it our website dynamically.

Above is the code for creating our table in our database which will hold the text and image. We need some text to show with the image so this text field will be used.

Now we will use the Drag and Drop Dropzone Jquery part. In this part we will add some jquery to create our drag and drop area workable. In this example you will see that we are uploading 5 images at a time.


Now we will create our form to upload the image. In form attribute action will be “getImage.php” and method will be post.

After putting this code you will see that there is a drag and drop area in your page. Some more code related to the styling i have added the boostrap and fontawesome. You can download the whole working zip from bottom of the article.


In this page we will write the code for uploading the image to the folder and save the image to the database. For uploading the image first of all we will check the $_FILE if we found it empty then we will show the error else we will start uploading the image.

In the above code you can see we have added a folder by the name of “gallery” where images will be uploaded. If you run the application till now then you can see that images are uploading in the folder successfully.

Now we will use the file name of uploaded image and save it to our database. Now we will just update the above code and it will send the filename and other values to the “imageClass.php”.

As you can see we have added some more code to the above code. Now this code will get the image file name and save it to the database. we have added some more data also which will be used in enabling and positioning the data.


In this class we will add our functions for adding the image to our database with status and position. You will find some more functions also which can be used for other things like – listing the images

Above code will list and add the  images.


This part is just for declaring the database connection and use it in the project.


This file will show you the added images over the website.

Hope you like the Upload Multiple Images Using PHP tutorial. if you have face any issue or have any questions then please comment below.

36.5 KiB

Comments (5) on "Upload Multiple Images Using PHP | Drag and Drop Image Upload"

  1. Everything is very open with a very clear description of the issues.

    It was definitely informative. Your site is extremely helpful.
    Many thanks for sharing!

  2. Thanks alot for this. Was wondering why it only works on local server. Keeps giving errors when i tried it on live server

    1. Debug and check that you have uploaded all the files in your server and they are connected properly to your page

Leave a Reply

Your email address will not be published. Required fields are marked *