Classes to manage file upload with symfony or package http-foundation.
This package is in charge of Geting the file uploaded, and move it to a new path, with a secure name.
It also allows to replace a file by the new uploaded.
- PHP 8.1
- Symfony 6.4 or package http-foundation
-
Install
composer require victor-codigo/upload-file
-
Classes
- UploadFileService: It is the main class. Manages file uploads.
- FileSymfonyAdapter: It is a wrapper for http-foundation package class File.
- UploadedFileSymfonyAdapter: Its a wrapper for http-foundation package class UploadedFile.
Method | Description | Params | Return |
---|---|---|---|
__construct | Creates class instance | Symfony\Component\String\Slugger\SluggerInterface | VictorCodigo\UploadFile\Adapter\UploadFileService |
__invoke | Moves the uploaded file to a new location | 1. VictorCodigo\UploadFile\Domain\UploadedFileInterface: The file uploaded. 2. string: path where files are uploaded. 3. string or null: File name to remove in uploads path. |
VictorCodigo\UploadFile\Domain\FileInterface |
getFileName | Gets the name of the file, after been renamed | string | |
getNewInstance | Creates a new instance of the class | VictorCodigo\UploadFile\Adapter\UploadFileService |