Download the PHP package tiloweb/uploaded-file-type-bundle without Composer
On this page you can find all versions of the php package tiloweb/uploaded-file-type-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tiloweb/uploaded-file-type-bundle
More information about tiloweb/uploaded-file-type-bundle
Files in tiloweb/uploaded-file-type-bundle
Package uploaded-file-type-bundle
Short Description A Symfony bundle that handle the form FileType upload and store the URL for you
License MIT
Informations about the package uploaded-file-type-bundle
UploadedFileType Bundle
Don't handle the upload, storage, and access logic of your entities images ! Just point where you want to upload the file, and only store the URL of it.
Installation
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
Applications that don't use Symfony Flex
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
Configuration
Step 1 : Configure your filesystem
Use the OneUp FlySystem bundle to configure the filesystem you want to work with.
Step 2 : create a default configuration
You can create many configurations, here, you will use the default
configuration :
filesystem
: the alias to the OneUp FlySystem you want to use.base_uri
: the URL to access to the root of your filesystem.path
: The folder you want to upload your file to.
Usage
Simple as 🦆 !
Juste create a Form with a FileType field, with the option upload
:
When the form will be submited, the file will be uploaded by the filesystem of the default
configuration, the URL of the file will be constructed and stored in your $image
field.
You are able to change the naming strategy of your file once stored on your filesystem. To do so, you can add a filename
option to your FileType
pointing to an enclosure taking 2 parameters :
UploadedFile $file
will contain the file uploaded by through formUploadedFile $item
will contain the data object of your form.
By default, the naming strategy is :
Example
Here, you will create a form in order to create a Retail
entity with a logo that you want to store on the server.
If you submit the form after having selected on your computer the image logo.png
, the file will be stored in public/upload/retail/logo.ee2a6cd0ed54b0f9e625698ae909d7ff.png
and the Retail::$logo
will store the URL https://www.example.com/upload/retail/logo.ee2a6cd0ed54b0f9e625698ae909d7ff.png
.
Reporting an issue or a feature request
Issues and feature requests are tracked in the Github issue tracker.
When reporting a bug, it may be a good idea to reproduce it in a basic project built using the symfony/website-skeleton to allow developers of the bundle to reproduce the issue by simply cloning it and following some steps.
All versions of uploaded-file-type-bundle with dependencies
oneup/flysystem-bundle Version ^4.0||^3.0
symfony/framework-bundle Version ^5.2||^6.0
symfony/twig-bundle Version ^5.2||^6.0
symfony/yaml Version ^5.2||^6.0
symfony/form Version ^5.2||^6.0