承接 antonio150/uploadimagebundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

antonio150/uploadimagebundle

Composer 安装命令:

composer require antonio150/uploadimagebundle

包简介

Un bundle Symfony pour l'upload d'images

README 文档

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

统计信息

  • 总下载量: 271
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-02-03