There is no license information available for the latest version (v1.1.3) of this package.

Helper for upload different files.

v1.1.3 2017-06-15 13:14 UTC

This package is auto-updated.

Last update: 2022-09-08 02:43:01 UTC


Manage - filter, validate and upload files.


Add in you composer.json file:

    "require": {
        "tasmaniski/upload-helper": "^1.0"

Don't forget to run composer update.


use Zend\Http\PhpEnvironment\Request;
use UploadHelper\Upload;

$files              = (new Request())->getFiles();                  // Return all files from $_FILE
$public_path        = '/var/www/website/public/uploads';            // better read it from config
$non_public_path    = '/var/www/website/data/uploads';
$upload             = new Upload($public_path, $non_public_path);   // Build upload object

$image = $upload->filterImage($files, 'image_name');  // image_name is the name from HTML form file input
$name  = $upload->uploadFile($image, 'image_name');   // After this the file is uploaded :) 
$path  = $upload->getWebPath($name);                  // If you need path for the Web or API

var_dump($name, $path);

Will display:
32f45151a816ffe96d571964f64faa20.png                    // File name
/uploads/3/2/f/32f45151a816ffe96d571964f64faa20.png     // Path to file