infw / file-manager
File Manager for In Framework
0.0.1.2
2016-10-27 22:24 UTC
Requires
- php: ^5.6
- infw/file: ^0.0.1
- infw/range: ^0.0.1
- infw/size: ^0.0.1
Requires (Dev)
- henrikbjorn/phpspec-code-coverage: ^3.0
- memio/spec-gen: ^0.6
- phpspec/phpspec: ^3.0
This package is auto-updated.
Last update: 2024-11-18 09:39:42 UTC
README
File manager provides a basic system storage for files, It uses "In Framework" File object as DTO.
It has a SendToStorage
service to persist files in filesystem.
Installation:
composer require infw/file-manager
Usage:
<?php use InFw\File\BaseMimeTypeFactory; use InFw\File\GenericFileFactory; use InFw\File\MimeTypes; use InFw\Size\BaseSizeFactory; use InFw\FileManager\BasicStorage; use InFw\FileManager\UploadToStorage; $config = [ 'root_path' => '/var/file-storage/', 'min_size' => 20, 'max_size' => 140000 ]; $factory = new GenericFileFactory( new BaseMimeTypeFactory( MimeTypes::IMAGES ), new BaseSizeFactory( $config['min_size'], $config['max_size'] ) ); /** @var \InFw\FileManager\StorageInterface $filesystem */ $filesystem = new BasicStorage($config['root_path']); $upload = new UploadToStorage($filesystem, $factory); // Assuming your form has an input type=file field named "upload" and an input type=name named "file_name". /** @var \InFw\File\FileInterface $file */ $file = $upload->sendToStorage($_FILES['upload'][0]['tmp_name'], $_POST['file_name']);