PHP Classes

Learn from a PHP Multiple File Upload Example Script Using the Package Multiple File Upload Processing: Validate and store files uploaded via Web forms

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-02-08 (10 days ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
multiple-file-upload 1.0BSD License5HTML, PHP 5, Files and Folders
Description 

Author

This package can validate and store files uploaded via Web forms.

It provides a class that can process an array from the $_FILES super-global variable with the details of one or more files uploaded using a Web form.

The class can check if all the files were uploaded correctly if they are of one of the allowed file types and does not exceed a given limit.

Valid file uploads are stored in a given directory.

Picture of Milan Jankovic
  Performance   Level  
Name: Milan Jankovic <contact>
Classes: 2 packages by
Country: Serbia Serbia

Example

<?php require_once 'classes/upload.class.php'; ?>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Multiple File Upload</title>
</head>
<body>
    <h2>Upload Multiple Files</h2>
<?php
try {

if (isset(
$_POST['upload'])) {
   
$upload = new Upload('uploads/');
   
$uploadStatus = $upload->uploadFiles($_FILES['files']);
    foreach (
$uploadStatus as $name => $status) {
        echo
$name . ' - ' . $status . '<br>';
    }
// foreach


}

} catch (
PDOException $e) {
    echo
$e->getMessage();
}

?>
<form action="" method="post" enctype="multipart/form-data">
        <input type="file" name="files[]" multiple>
        <input type="submit" name="upload" value="Upload">
    </form>
</body>
</html>


  Files folder image Files (9)  
File Role Description
Files folder imageclasses (1 file)
Files folder imageuploads (7 files)
Accessible without login Plain text file index.php Example Example script

  Files folder image Files (9)  /  classes  
File Role Description
  Plain text file upload.class.php Class Class source

  Files folder image Files (9)  /  uploads  
File Role Description
  Accessible without login Image file 1.png Icon Icon image
  Accessible without login Image file 11.png Icon Icon image
  Accessible without login Image file 2.png Icon Icon image
  Accessible without login Image file 22.png Icon Icon image
  Accessible without login Image file 3.png Icon Icon image
  Accessible without login Image file 6.png Icon Icon image
  Accessible without login Image file 8.png Icon Icon image

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0