2017 © Pedro Peláez
 

library file_uploader

PHP File Uploader Package

image

clivern/file_uploader

PHP File Uploader Package

  • Friday, September 16, 2016
  • by clivern
  • Repository
  • 1 Watchers
  • 12 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

File Uploader

PHP File Uploader Package, (*1)

Current version: [v1.0.2], (*2)

Build Status Latest Stable Version License, (*3)

Installation

Via Composer, (*4)

``` bash $ composer require clivern/file_uploader, (*5)


## Usage First configure uploader class. ``` php include_once dirname(__FILE__) . '/vendor/autoload.php'; $uploader = new \Clivern\FileUploader\Uploader([ 'dir_path' => dirname(__FILE__), # Path to storage directory 'dir_name' => 'storage', # Storage directory name 'year_storage_based' => true, # Whether to arrange uploaded file in year directories 'month_storage_based' => true, # Whether to arrange uploaded file in months under year directories ]);

Then upload and validate file, (*6)

$result = $uploader->uploadFile('test', [ # test is the file input name

    # validate allowed extensions
    # Possible values are:
    #   false => to stop extension validation.
    #   array of allowed extensions.
    'supported_extensions' => ['txt'],

    # validate allowed types
    # Possible values are:
    #   false => to stop type validation.
    #   array of allowed types.
    'supported_types' => ['text/plain'],

    # Maximum upload size
    # Possible values are:
    #   false => to stop size validation.
    #   1KB or 2KB or 8KB and so on.
    #   2MB or 3MB or 8MB and so on.
    #   3GB or 4GB or 5GB and so on.
    #   4TP or 8TP or 10TP and so on.
    #   9PB or 8PB and so on.
    'max_size' => '2MB',
]);

Then check if file uploaded, (*7)

if (!$result) {
    # Get Errors List
    $errors = $uploader->getErrors();
}else{
    # Get uploaded file info
    $file_info = $uploader->getFileInfo();
}

Explore this working example, (*8)

 dirname(__FILE__), # Path to storage directory
        'dir_name' => 'storage', # Storage directory name
        'year_storage_based' => true, # Whether to arrange uploaded file in year directories
        'month_storage_based' => true, # Whether to arrange uploaded file in months under year directories
    ]);

    $result = $uploader->uploadFile('test', [ # test is the file input name

        # validate allowed extensions
        # Possible values are:
        #   false => to stop extension validation.
        #   array of allowed extensions.
        'supported_extensions' => ['txt'],

        # validate allowed types
        # Possible values are:
        #   false => to stop type validation.
        #   array of allowed types.
        'supported_types' => ['text/plain'],

        # Maximum upload size
        # Possible values are:
        #   false => to stop size validation.
        #   1KB or 2KB or 8KB and so on.
        #   2MB or 3MB or 8MB and so on.
        #   3GB or 4GB or 5GB and so on.
        #   4TP or 8TP or 10TP and so on.
        #   9PB or 8PB and so on.
        'max_size' => '2MB',
    ]);

    echo '
';
    if (!$result) {
        # Get Errors List
        $errors = $uploader->getErrors();
        var_dump($errors);
    }else{
        # Get uploaded file info
        $file_info = $uploader->getFileInfo();
        var_dump($file_info);
    }
    die();
}

?>



Change log

Version 1.0.2
> Initial Release

Testing

bash $ composer test, (*9)

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*10)

Security

If you discover any security related issues, please email hello@clivern.com instead of using the issue tracker., (*11)

License

The MIT License (MIT). Please see License File for more information., (*12)

The Versions

16/09 2016

dev-master

9999999-dev https://github.com/clivern/file_uploader

PHP File Uploader Package

  Sources   Download

MIT

The Requires

  • php ~5.4|~7.0

 

The Development Requires

clivern file_uploader

18/06 2016

v1.0.2

1.0.2.0 https://github.com/clivern/file_uploader

PHP File Uploader Package

  Sources   Download

MIT

The Requires

  • php ~5.4|~7.0

 

The Development Requires

clivern file_uploader

18/06 2016

v1.0.1

1.0.1.0 https://github.com/clivern/file_uploader

PHP File Uploader Package

  Sources   Download

MIT

The Requires

  • php ~5.4|~7.0

 

The Development Requires

clivern file_uploader

17/06 2016

v1.0.0

1.0.0.0 https://github.com/clivern/file_uploader

PHP File Uploader Package

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

clivern file_uploader