antonio150 / uploadimagebundle
Un bundle Symfony pour l'upload d'images
Installs: 97
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.1
- symfony/framework-bundle: ^5.0 || ^6.0 || ^7.0
This package is auto-updated.
Last update: 2025-06-22 18:55:06 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); } } }
Contact
Portfolio : antonio navira