programster / upload-file-manager
A library to make handling file uploads easier.
Installs: 1 446
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.4.0
Requires (Dev)
This package is not auto-updated.
Last update: 2024-11-06 08:48:50 UTC
README
A package to make it easy to deal with upload files.
Install
composer require programster/upload-file-manager
Example Usage
$uploadManager = new Programster\UploadFileManager\UploadFileManager(); $files = $uploadManager->getUploadFiles(); if (count($files) > 0) { /* @var $file Programster\UploadFileManager\UploadFile */ $uploadFile = $files['my_file_input_field_name']; if ($uploadFile->hasError()) { throw $file->getException(); } else { // Upload was successful, do something with the file here. $uploadFile->getFilepath(); $uploadFile->getSize(); $uploadFile->getName(); $uploadFile->getMimeType(); } }
If your form has multiple input fields for files:
$uploadManager = new Programster\UploadFileManager\UploadFileManager(); $files = $uploadManager->getUploadFiles(); if (count($files) > 0) { // some files were uploaded, loop thorugh them. foreach ($files as $inputFieldName => $file) { /* @var $file Programster\UploadFileManager\UploadFile */ if ($file->hasError()) { throw $file->getException(); } else { // Upload was successful, do something with the file here. $uploadFile->getFilepath(); $uploadFile->getSize(); $uploadFile->getName(); $uploadFile->getMimeType(); } } }