2017 © Pedro Peláez
 

library file-uploader

File uploader for PHP

image

pa-bru/file-uploader

File uploader for PHP

  • Tuesday, January 31, 2017
  • by pa-bru
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

FileUploader!

Presentation

FileUploader is a php class which enables you to upload files on your website !, (*1)

features :

  • Upload various type of files. You can choose the allowed formats.
  • Rename uploaded files
  • Choose location of the uploaded files
  • Image resizing

Installation

FileUploader is available via Composer/Packagist, so just add this line to your composer.json file:, (*2)

"pa-bru/file-uploader": "~1.0"

or, (*3)

composer require pa-bru/file-uploader

Usage

Call the class:


$file = $_FILES["myfile"]; $args = [ "fileName" => "my-filename", "contentDir" => "my-directory/", "allowedExts" => array(), "maxSize" => 1000000, "width" => 200, "height" => 300 ]; $uploader = new FileUploader($file, $args);

$file : File upload data table $file is required, (*4)

$args : table arguments that can be passed to the constructor $args is optional. eg: $uploader = new FileUploader($file);, (*5)

Properties

  • fileName : name of file. If not specified, a single string is assigned.
  • contentDir : Destination folder of the file added. The folder is created if it does not exist.
  • allowedExts : Table of allowed extensions.
  • maxSize : The maximum file size in bytes.
  • width : In pixel (px) for resizing images (PNG, JPEG, JPG, GIF).
  • height : In pixel (px) for resizing images (PNG, JPEG, JPG, GIF).

Get the parameters (Getters) :

  • Get file extension :
$uploader->getFileExtension();
  • Get the destination path of the file :
$uploader->getPath();
  • Get the height to be assigned to the image file :
$uploader->getHeight();
  • Get the width to be assigned to the image file :
$uploader->getWidth();
  • Get the maximum file size :
$uploader->getMaxSize();
  • Get the destination folder of the file :
$uploader->getContentDir();
  • Get the filename :
$uploader->getFileName();
  • Get file data table :
$uploader->getTmpFile();
  • Get the allowed extensions for uploading a file :
$uploader->getAllowedExts();

Set the parameters (Setters) :

  • Set file path :
$uploader->setPath($path);
  • Set the height to be assigned to the file (if it is an image) :
$uploader->setHeight($height);
  • Set the width to be assigned to the file (if it is an image):
$uploader->setWidth($width);
  • Set the maximum size allowed for file upload :
$uploader->setMaxSize($maxSize);
  • Set the destination folder of the file :
$uploader->setContentDir($contentDir);
  • Set the name to be assigned to the file :
$uploader->setFileName($fileName);
  • Set the file to upload :
$uploader->setTmpFile($tmpFile);
  • Set the table of allowed extensions for file upload :
$uploader->setAllowedExts(array $allowedExts);

Launch upload :

$uploader->upload();

If successful the upload () method returns the path of the uploaded file., (*6)

Releases

v1.0 : * Initial Version, (*7)

Author

Copyright © 2016 Paul-Adrien Bru | MIT license, (*8)

The Versions

31/01 2017

dev-master

9999999-dev https://github.com/Seldaek/monolog

File uploader for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

file upload image uploader file uploader

31/01 2017

v1.0

1.0.0.0 https://github.com/Seldaek/monolog

File uploader for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

file upload image uploader file uploader