PHP Classes

File: ajax.php

Recommend this page to a friend!
  Classes of manudg   PHP Upload Multiple Images Ajax   ajax.php   Download  
File: ajax.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Upload Multiple Images Ajax
Process uploaded images sent via AJAX requests
Author: By
Last change: 1.0.1
Date: 8 years ago
Size: 1,156 bytes
 

Contents

Class file image Download
<?php
require "php/class.uploadImages.php";

$uploadImages = new uploadImages();

/* Images are required */
if ($uploadImages->countImages() > 0)
{
   
   
/* Default validation:
        $uploadImages->image_type = "jpg|jpeg|png|gif";
        $uploadImages->min_size = "";
        $uploadImages->min_size = 24;
        $uploadImages->max_size = (1024*1024*3);
        $uploadImages->max_files = 10;
    */
   
    /* Validate */
   
if ($uploadImages->validateImages())
    {
        print(
"<h3 class='text-info'>IMAGES</h3>");
       
/* images array */
       
$images = $uploadImages->getImages();
        foreach (
$images as $image)
        {
           
/* save the image */
           
if ($uploadImages->saveImage($image["tmp_name"], "images/", $image["name"]))
            {
                print (
"<p class='text-success'>· <strong>" . $image["name"] . "</strong> saved in images folder</p>");
            }
            else
            {
                print(
"<p class='text-danger'>· " . $image["name"] . " error to saved</p>");
            }
        }
       
/* GET EXTRA PARAMETERS */
       
print("<h3 class='text-info'>EXTRA PARAMETERS</h3>");
       
print_r($uploadImages->getParams());
    }
    else
/* Show errors array */
   
{
       
print_r($uploadImages->error);
    }
}
else
{
    print(
"<p class='text-danger'>images required</p>");
}