How to implement file uploads in EasyAdmin?

Development
18.06.2025
Nico Zeier
Foto von Carlos Muza auf Unsplash

What is EasyAdmin?

EasyAdmin is a wonderful framework for Symfony that allows developers to build very powerful admin interfaces. Very easily a developer can spin up interfaces for users that allow them to interact with a specified set of entities, for example to run a blog or manage some products. We use Easy Admin in nearly all our projects, as its very neatly integrated with Symfony, but also actively developed. We even contributed to the package a couple of times already. EasyAdmin allows developers to build really strong and versatile backends, and together with Symfony its a really strong software project.


The Problem with EasyAdmin

Default Limitations

Although EasyAdmin is known for its straight forward user interface and the ability to customize according to individual needs, it has some drawdowns. For example the design of the codebase. Whilst some classes are marked as final, they do not implement any kind of Interfaces. Usually when approaching this design pattern, you always want to implement Interfaces or at least focus on the SOLID principle, so that other developers can write tests for their business logic. In general, that would be the preferred approach. But since Symfony has so many contributers, there are also so many ideas how code should look like. This is typical. The more developers you have, the more good and bad ideas you will get. Another problem with EasyAdmin is that it can be hard and frustrating to bring code improvments in, as there is no real order of command and basically the owners is signing off every single contribution by himself; naturally, nobody has so much time to maintain such a package next to their daily job. Meaning that many Pull Requests are open for a long time, demotivating the contributers. Frankly, this is understandable.But the real challenge is not withing this kind of merging strategy, but in the narrow and somewhat suboptimal developed spaces inside the code that are not extensible.


Complexity of Customization

Now lets say you want to add a new field - straight forward! Its very easy to create a new field in your own codebase and using it. But if you want to contribute that logic into EasyAdmin directly, it can be more challenging. A good example for this is the lack of a Field that allows developers to implement classic File Upload Fields. One could say that these fields might bring in Security issues and whilst we'd agree with this statement, isn't that up to the developer to secure? Depending on how you see Open Source projects you might agree. In our case we wanted to have a File Field. There is an Image Field that has everything we need, but we want to adapt a small fraction of the code, just so much that we can upload Files, together with Images in one field.


The Solution: EasyAdmin File Upload Field Plugin

A little big more Freedom for Developers

We work with a client that needs to upload given files. Word documents, PDFs, CSVs, you name it - its not possible with the current branch of EasyAdmin. For this reason we developed our own little package, kept it tightly to the code standards of EasyAdmin and published it to composer for you to use it very easily.

Usage

If you find yourself in a situation where you want to have File Fields as well, you can go ahead and use our free EasyAdmin Field bundle for free. Simply type:

composer require bytescommerce/easy-admin-file-upload-field

You should by now use PHP 8 and Symfony 7, so you should have Flex enabled. In this case, the bundle will register itself with the developers EasyAdmin application. Now, its very easy to integrate it.

The old ImageField can now be replaced with our FileField:

yield FileField::new('filename', t('File'))
->setBasePath(sprintf('%s', File::BASE_FILE_PATH))
->setUploadDir(sprintf('public/%s', File::BASE_FILE_PATH))
->setUploadedFileNamePattern('[name].[extension]')
->setColumns('col-sm-12 col-md-6');


As you can see, not much changes here. We only replaced "ImageField" with FileField and imported our class to be used succesfully. And thats it, the bundle will re-use the ImageField assets and resources, but manipulates the upload constraints.


Advantages of Our Plugin

Easy Installation

Thanks to composer you can absolutely don't waste your time on installation. Like its common in the Symfony world, packages are provided with composer quite easily.

Versatile Applications

Our plugin stands out due to its versatility. Whether it is about uploading images, documents, or other file formats, the integration of this component into the EasyAdmin backend brings significant advantages. The plugin offers the necessary flexibility to efficiently manage various file types, making it the ideal solution for a wide range of use cases.

Same User Interface as before!

Your users won't even notice. Since we do re-use all components from the classic ImageField, there is not even a slight change in the UI. It remains absolutely the same.

Contributions

If you find yourself in a situation where you have found a bug in our code, feel free to open a PR with us; we are happy to receive your input.


Find the project on Github!

Pattern Pattern Pattern

Fragen und Antworten

EasyAdmin does not have a built-in file upload function by default, which poses a challenge for web developers. Without this functionality, developers have to resort to complicated workarounds or additional libraries, complicating and slowing down the development process.

The plugin enables developers to seamlessly integrate file upload fields such as FileField and ImageField into EasyAdmin. This eliminates the complexity of custom implementations, saving time and reducing the risk of potential issues in the applications.

In modern web applications, uploading files such as images and documents is often an integral component. It supports functions like managing user profile pictures and adding media content, significantly enhancing the user experience.

The easyadmin-file-upload-field Plugin impresses with its user-centric interface, which enables both developers and administrators to intuitively manage file uploads. This user-friendliness simplifies interactions and boosts the overall efficiency of the application.

The easyadmin-file-upload-field Plugin is highly versatile and supports the uploading of various file types, including images and documents. This flexibility makes it the ideal solution for a wide range of use cases.

The installation of the easyadmin-file-upload-field Plugin is straightforward and quick, allowing developers to get started with minimal hassle. Only a few steps are needed to integrate the plugin into existing EasyAdmin implementations, significantly reducing administrative effort.

By providing a standardized and proven mechanism for file uploads, the easyadmin-file-upload-field Plugin reduces the need for custom, error-prone modifications. This minimizes the risk of stability issues and security vulnerabilities in the application.

Yes, the easyadmin-file-upload-field Plugin offers high flexibility and can be adapted to the specific needs of a project. It enables efficient management of various file types, ensuring that individual user expectations are met.

The flexibility of the easyadmin-file-upload-field Plugin allows developers to customize the upload functionality to fit specific project requirements. This saves valuable development time and ensures that the application meets end-user expectations, leading to greater satisfaction.

Professional implementation services can assist in efficiently and purposefully integrating the easyadmin-file-upload-field Plugin into complex projects. They offer support with customizations, optimizations, and ensuring that all project requirements are fully met.

Ihr IT-Dienstleister in München, Augsburg und Umgebung

Wir bringen Ihr Unternehmen aufs nächste Level

Jetzt kontaktieren
Illustration

Unsere IT-Dienstleistungen:


Ihre neue Landingpage: In Rekordzeit online

Sparen Sie Zeit und Ressourcen – wir designen, optimieren und launchen Ihre Landingpage, während Sie sich um Ihr Kerngeschäft kümmern.

Mehr erfahren
NEU
Bytes Commerce AI Landingpages