Photo Image gallery V1

This is a simple script for creating and managing image gallery. Using this script we can add , delete and manage photo gallery.


  1. Users can create galleries
  2. While uploading photos users can select one gallery
  3. Users can browse through the galleries or Photos
  4. Navigation to previous or next photo shown by the side of the main photo.

Site Admin Features

  1. Site admin can delete galleries and empty the gallery.
  2. Delete photo and can add title to the photos.
  3. Change login password
  4. Select any gallery to delete or add title to photos.
Photo gallery

Script requirement

PHP 5 ( Version ) and above with PDO support for MySQL database
Write permission to store upload images and directory config.php
Enter your MySQL database details ( login id , password , database name , server ).

Storing uploaded images

Inside config.php file you can set the location of uploaded image and the created thumbnail image. Note that the path is set relative to directory where script is executed.

By default we have kept two directories in script root and name of the directories are set in above variables. You can change them as per your requirement. Donít forget to give write permission to these directories to store images.

How to install the script.

Download the zip file at the end of this page. Place the files in your server with PHP and MySQL.
Use the sql_dump.txt file to create your tables.

Entering site admin login details.

In your server open the install.php file kept inside admin folder.
Enter your userid and password using the form provided.

For security reasons remove the install.php ( inside Admin folder ) file after adding admin login details to table.

Features of Admin area

There is a login system to allow site admin to enter into admin area. For this the admin login details are stored in a table. User can use the install script to add admin userid and password. User can login and change the password. The login system is similar to member login system explained here.

There is a top link to navigate between different pages of admin area.

manage-photos.php : Managing Photos
Managing Photos in a gallery
This page uses Ajax to update data. This page also uses paging of records to display 10 thumbnail images. You can change the setting inside page to display different number of records per page.

Below each thumbnail image there is delete button to delete the image. There is a edit button to show a text field to enter title for the picture.

By default it displays all the images ( with paging of 10 records per page ) in the order of recently added photos showing first. At the end of the page there is a drop down to select one gallery. On Select of a gallery the page will refresh and show photos of selected gallery only.

manage-gallery.php ( managing gallery )
Managing gallery
Photos are stored under one gallery. Users can create gallery while uploading photos. In this page all galleries listed with number of photos inside the gallery. There is a button to delete the gallery. A message box will be displayed asking users to confirm again before deleting the gallery and images.

On confirmation by the user all the filenames under the galley is collected and matching image files from upload and thumbnail directory are deleted. Then the records are deleted from plus2net_image tables and plus2net_gallery table.

Features of user area

User area is kept open (without login ) in this script. You can integrate it to your secured area by adding checkings at top of the page.

Userid can be added to the uploaded records with gallery and photo information.
Adding Photos to a gallery
Users can use this file to upload images. Click Choose file button, browser window from local computer will be displayed. You can select images by clicking the file you want to upload. Hold the Ctrl button to select multiple images. Click the attach button to connect the images. Click the Upload Image button to start uploading of images. Note that only JPG files are allowed to upload.

Adding gallery by user

Adding Gallery

Users always upload images based on some area or event like winter garden flowers, sea beach, school union function etc. user will create gallery first and before uploading they have to select one gallery to assign against each photo uploaded. uploadck.php The file processing script is kept inside uploadck.php. This file we will execute in an iframe. So we can display uploaded images ( thumbnail image ) inside iframe so user can check the uploaded status. This script gets uploaded

User has to select one gallery before uploading, script will check gallery name and if not present then will stop script execution.

Resize of images

After uploading the image is resized to 890 width and the height proportionally changed to maintain the aspect ratio . Thumbnail image size also can be set here. The variables are set like this.

You can change the above values inside uploadck.php file.

Thumbnail creation

One thumbnail image is created using the dimensions set by variables ( shown above ). Each image ( after resizing to 890 size ) will have one thumbnail image kept in a different folder. The main image ( of 890 size ) and thumbnail image both have same file name but kept in different folders.

This file receives gallery id from query string and gets all the photos using the gallery id. As we are using gal_id from query string so we must sanitize the variable before using inside our query. We will only allow integers as gal_id.

This page will use paging of records and by default it is set to 10 records per page. You can change it by changing the assigned value to the variable.

You can click any thumbnail displayed here to visit the full size photo page. photo.php
This page receives img_id from query string and display the big ( original ) photo. At the same time it will display thumbnail image of previous and next photo of same gallery. So users can easily navigate to other photos of the same gallery.

Additions to this script

To make it simple several features are not added to this script. Here are some of them.
  1. Integration with user signup page
  2. Photo page will have visitor posting comment section
  3. Photo page visitors can submit rating in one to five scale.
  4. Home page will display highest rated photo
  5. Category to be created by site admin. Each gallery has to be associated with one category.
  6. While creating a gallery user has to select category first. Example : User can add LA beach gallery under category Sea Beaches.
  7. User can manage gallery and their photos.
Feel free to post your comments below ( or use the forum ) for any clarification or suggestion.

Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net



    Best Demo for image storage...
    Thanks :)


    Thanks for the code. :D
    How can I get the additional script, I want to user can add/change the title of the picture.
    Cause in this code, if we upload the picture, the title will filled as NULL in the "plus2net_image" table.
    Thanks again :D


    best demo thank's :)


    This article is of great help. However, I got a problem, in the admin section for manage photos , the uploaded photo cannot be deleted or updated. The page shows please wait.. and freezes. I am new to php. I was wondering what might be the problem. I am using latest version of xampp .


    Are you able to login to admin section ? While installing the script you can create login id and password for admin. Using that you can enter into Admin area and manage the photos. Download a fresh copy of the script from here and try


    When I enter a gallery name and press Add Gallery the wait icon keeps on spinning and nothing executes. The entire folder is in another folder. But if it is at the root of the server it works. Are there any other changes to be configured?


    DB name is changed, download a fresh copy and use.

    Post your comments , suggestion , error , requirements etc here .

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer