PHP Classes
elePHPant
Icontem

File: example_for_multi_files_upload.php

Recommend this page to a friend!
  Classes of MOUSTAFA ELGAMMAL  >  PHP Multi File Uploader  >  example_for_multi_files_upload.php  >  Download  
File: example_for_multi_files_upload.php
Role: Example script
Content type: text/plain
Description: multi files exampe
Class: PHP Multi File Uploader
Validate and process one or more file uploads
Author: By
Last change:
Date: 3 years ago
Size: 1,390 bytes
 

 

Contents

Class file image Download
<form action="example_for_multi_files_upload.php" method="post"
    enctype="multipart/form-data">
    <input type="file" name="images[]" multiple /> <input type="submit"
        name="submit" />
</form>
<hr>
<?php
require_once 'classes/MultiFileUploader.class.php';

if (isset (
$_POST ['submit'] )) {
    echo
"<pre>";
   
// var_dump($_FILES['images']);
   
if (isset ( $_FILES ['images'] )) {
       
$files_data = $_FILES ['images'];
       
$uploading_directory = 'uploads/multi'; // uploading directory
       
        /**
         * for example if your upload images
         *
         * @var $files_types
         */
       
$files_types = array (
               
'image/jpg',
               
'image/jpeg',
               
'image/png',
               
'image/gif'
       
);
       
       
/**
         * for example exts types of the images
         *
         * @var $files_exts
         */
       
$files_exts = array (
               
'jpg',
               
'jpeg',
               
'gif',
               
'png'
       
);
       
       
// new object of the MultiFileUploader class
       
$up = new MultiFileUploader ( $files_data, $uploading_directory, $files_types, $files_exts );
       
       
$up->start_upload (); // init files data
       
        /**
         * MultiFileUploader::finish_upload ()
         * upload the files with check every validation
         * then @return an array with to index
         * 1st index "uploaded": the names of the uploaded files
         * 2nd index "errors" : array of errors of Invalid files validation
         */
       
var_dump ( $up->finish_upload () );
    }
}

?>