2017 © Pedro Peláez
 

library fileupload

Coercive File Upload Utility

image

coercive/fileupload

Coercive File Upload Utility

  • Wednesday, February 7, 2018
  • by Coercive
  • Repository
  • 1 Watchers
  • 2 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Coercive FileUpload Utility

FileUpload enables you to manage file shipments : moving, copying , deleting temporary files , retrieving information ..., (*1)

Get

composer require coercive/fileupload

Usage

IMAGE, (*2)

use Coercive\Utility\FileUpload;

# EXAMPLE IMAGE FILE
$oImageUpload = new ImageUpload([
    ImageUpload::OPTIONS_NAME => 'img_file',
    ImageUpload::OPTIONS_ALLOWED_EXTENSIONS => ['jpeg', 'jpg', 'gif', 'png']
]);

# ERRORS
if($oImageUpload->getErrors()) { exit; }

# SAVE : add extension auto
$oImageUpload->save('/example/path/' . $sImgName_auto_extension);
if($oImageUpload->getErrors()) { exit; }

# Where is my file ?
$sMyFile = $oImageUpload->getDestPath();

FILE, (*3)

use Coercive\Utility\FileUpload;

# EXAMPLE FILE
$oFileUpload = new FileUpload([
    FileUpload::OPTIONS_NAME => 'file',
    FileUpload::OPTIONS_ALLOWED_EXTENSIONS => ['pdf']
]);

# ERRORS
if($oFileUpload->getErrors()) { exit; }

# SAVE
$oFileUpload->save('/example/path/' . $sFileName . '.pdf');
if($oFileUpload->getErrors()) { exit; }

MOD, (*4)


# EXAMPLE MOD $oFileUpload = new FileUpload([ FileUpload::OPTIONS_NAME => 'file', FileUpload::OPTIONS_CHMOD_DIR => 0777, # IF DIRECTORY NOT EXIST FileUpload::OPTIONS_CHMOD_FILE => 0777 # WHEN USE MOVE OR COPY ]); # YOU CAN USE INTERNAL HELPER $oFileUpload = new FileUpload([ [ ... ] FileUpload::OPTIONS_CHMOD_DIR => FileUpload::CHMOD_OWNER_WRITE, FileUpload::OPTIONS_CHMOD_FILE => FileUpload::CHMOD_OWNER_READ, [ ... ] ]); FileUpload::CHMOD_FULL; # 0777 FileUpload::CHMOD_OWNER_FULL; # 0700 FileUpload::CHMOD_OWNER_READ; # 0400 FileUpload::CHMOD_OWNER_WRITE; # 0200 FileUpload::CHMOD_OWNER_EXEC; # 0100 FileUpload::CHMOD_OWNER_FULL_GROUP_READ_EXEC; # 0750 FileUpload::CHMOD_OWNER_FULL_GROUP_READ_EXEC_GLOBAL_READ; # 0754 FileUpload::CHMOD_OWNER_FULL_GROUP_READ_EXEC_GLOBAL_READ_EXEC; # 0755 FileUpload::CHMOD_OWNER_READ_WRITE; # 0600 FileUpload::CHMOD_OWNER_READ_WRITE_GROUP_READ; # 0640 FileUpload::CHMOD_OWNER_READ_WRITE_GROUP_READ_GLOBAL_READ; # 0644

HELP, (*5)

use Coercive\Utility\FileUpload;

# Need Something ?
$oFileUpload
    ->getDestPath();
...
    ->getFilePathInfo();
...
    ->getMaxFileSize();
...
    ->getFileSize();
...
    ->getFileError();
...
    ->getFileType();
...
    ->getFilePath();
...
    ->getFileExtension();
...
    ->getFileName();
...
    ->getErrors();
...
    ->getChmodDir();
...
    ->getChmodFile();

# You can delete temp file by using :
$oFileUpload
    ->deleteTempFile();

OPTIONS, (*6)

# FileUpload / ImageUpload : Constructor Options
array(
    FileUpload::OPTIONS_NAME => '', # (string) input file name
    FileUpload::OPTIONS_ALLOWED_EXTENSIONS => [], # (array) of strings example : ['jpg', 'gif']
    FileUpload::OPTIONS_DISALLOWED_EXTENSIONS => [], # (array) of strings
    FileUpload::OPTIONS_MAX_SIZE => self::DEFAULT_MAX_SIZE, # (int) default : 10485760 (10 Mo)
    FileUpload::OPTIONS_CHMOD_DIR => self::DEFAULT_CHMOD_DIR, # (int) default : 0644
    FileUpload::OPTIONS_CHMOD_FILE => self::DEFAULT_CHMOD_FILE # (int) default : 0644
);

The Versions

07/02 2018

dev-master

9999999-dev http://coercive.fr

Coercive File Upload Utility

  Sources   Download

MIT GNU

The Requires

  • php >=5.4.0

 

07/02 2018

1.1.1

1.1.1.0 http://coercive.fr

Coercive File Upload Utility

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

16/07 2016

1.1

1.1.0.0 http://coercive.fr

Coercive File Upload Utility

  Sources   Download

GNU

The Requires

  • php >=5.4.0

 

10/07 2016

1.0.0

1.0.0.0 http://coercive.fr

Coercive File Upload Utility

  Sources   Download

GNU

The Requires

  • php >=5.4.0