victor-codigo/upload-file

Classes to manage file uploads

v1.0.2 2025-02-15 10:27 UTC

This package is auto-updated.

Last update: 2025-06-02 10:05:21 UTC


README

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.

Prerequisites

  • PHP 8.1
  • Symfony 6.4 or package http-foundation

Stack

Usage

  1. Install

    composer require victor-codigo/upload-file
    
  2. 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.

UploadFileService methods:

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