antonio150/uploadimagebundle

There is no license information available for the latest version (dev-main) of this package.

Un bundle Symfony pour l'upload d'images

Maintainers

Package info

github.com/antonio150/UploadImageBundle

Type:symfony-bundle

pkg:composer/antonio150/uploadimagebundle

Statistics

Installs: 273

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-01-13 13:21 UTC

This package is auto-updated.

Last update: 2026-03-13 13:37:00 UTC


README

Introduction

The UploadImageBundle is a Symfony bundle that provides an easy way to upload and manage files in your Symfony application.

Installation

To install the bundle, use Composer:

composer require antonio150/uploadimagebundle:dev-main

Configuration

Run commande to choose path to store file

symfony console upload-image-bundle:install

Add the bundle to your config/bundles.php file if missing:

return [
    // ...
    UploadImageBundle\UploadImageBundle::class => ['all' => true],
];

Usage

To use the bundle

Edit your controller :

     namespace App\Controller;
     use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
     use Symfony\Component\HttpFoundation\Request;
     use Symfony\Component\HttpFoundation\Response;
     use Symfony\Component\Routing\Attribute\Route;
     use UploadImageBundle\Service\FileUploader;

     final class UploadimageController extends AbstractController{

         
         #[Route('/uploadimage', name: 'app_uploadimage')]
         public function upload(Request $request, FileUploader $fileUploader): Response
         {
             $file = $request->files->get('file'); // Récupérer le fichier depuis la requête
             if (!$file) {
                 return $this->json(['error' => 'Aucun fichier envoyé'], Response::HTTP_BAD_REQUEST);
             }

             try {
                 $result = $fileUploader->upload($file); // To get path and file name
                 return $this->json($result);
             } catch (\Exception $e) {
                 return $this->json(['error' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
             }
         }

     }

Voici exemple de résultat

{
  "fileName" => "696646055d19e.jpg"
  "absolute_path" => "E:\Mes Projets\piasako2\public\uploads\images\696646055d19e.jpg"
  "public_path" => "/uploads/images/696646055d19e.jpg"
  "public_dir" => "/uploads/images"
}

Contact

Portfolio : antonio navira