Upload Image and Create Multiple Thumbnails using PHP

Thumbnails are reduced-size versions of pictures or videos, used to help in recognizing and organizing. Thumbnails are ideally implemented on web pages as separate, smaller copies of the original image, in part because one purpose of a thumbnail image on a web application is to reduce bandwidth and download time. In this post, we have share how to Upload Image and Create Multiple Thumbnails using PHP. File upload functionality is one of the most common requirements for most web applications. This is a very simple example, you can just copy paste and change according to your requirement.
Before started to implement the NUpload Image and Create Multiple Thumbnails using PHP, look files structure:
  • upload-image-and-create-multiple-thumbnails-php
    • assets
      • css
        • style.css
      • js
        • jquery.form.min.js
      • uploads
        • _large
        • _medium
        • _mobile
        • _thumb
      • images
    • templates
      • header.php
      • footer.php
    • index.php
    • functions.php
    • upload.php
Step 1: Create a function file
Create a file named functions.php
  • createFolder() – create new folder
  • generateThumbnail() – create multiple Thumbnails
Step 2: Create action file named upload.php
jQuery code handle AJAX request
Step 3: Create HTML file named index.php
Create files named (header.php and footer.php)
This file contains the header and footer section of the webpage. The Bootstrap library is used to provide a better UI, so, include it in the header and footer section.
header.php
footer.php