newwebsouth / upload
There is no license information available for the latest version (1.1.1) of this package.
Component of upload
1.1.1
2020-10-06 21:08 UTC
This package is not auto-updated.
Last update: 2025-04-16 16:34:32 UTC
README
The upload Manager help you for upload a file.
Configuration:
config/components/Upload.php
return [
'config_name' => [ <br>
UploadManagerInterface::PATH => '/var/sample/dir/',<br>
UploadManagerInterface::MAX_FILE_SIZE => 100000,<br>
UploadManagerInterface::ACCEPT_TYPE => [<br>
'type_1',<br>
'type_2',<br>
...<br>
],<br>
UploadManagerInterface::DUPLICATION_RULE => 'closure|string : iteration| string : overwrite| string : crash',<br>
UploadManagerInterface::WAIT_TRANSACTION => false|true
]<br>
]
For DUPLICATION_RULE
Closure: function(string $originalName){ ... }
"iteration": A number will be added to filename:
test.png = test(1).png
"overwrite": The file will be overwriting
"crash": You will receive a Newwebsouth\Upload\Exception\UploadDuplicationException::class
For WAIT_TRANSACTION
If true, the file will be upload when the transaction have success
Mappe the interface in container configuration
Method
upload(array $part, string $configurationName): array
return a metadata of document:
return [
UploadManagerInterface::META_LOCAL_PATH => $path,<br>
UploadManagerInterface::META_PUBLIC_PATH => public path (if is public ressource),<br>
UploadManagerInterface::META_SIZE => size of document,<br>
UploadManagerInterface::META_SHORT_NAME_WITH_EXTENSION => filename with extension,<br>
UploadManagerInterface::META_SHORT_NAME_WITHOUT_EXTENSION => filename without extension<br>
]