Symfony Bundle for adding a file picker component to form inputs
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require evansmwendwa/filepicker-bundle "dev-master"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Evans\FilepickerBundle\EvansFilepickerBundle(),
);
// ...
}
// ...
}
# app/config/config.yml
evans_filepicker:
uploads_destination: '/uploads/images'
allow_uploads: true
allowed_mimes: ['image/jpeg','image/png','image/gif']
group_files: false
# Twig Configuration
twig:
form_themes:
- EvansFilepickerBundle::form/fields.html.twig
The bundle provides two twig functions for loading the necessary HTML, CSS and JS. Add these functions somewhere in your twig template. Can be base in you base template if necessary
# loads necessary html and js files
{{ file_picker_init() }}
# loads necessary css files
{{ file_picker_init_css() }}
# app/config/routing.yml
evans_filepicker:
resource: "@EvansFilepickerBundle/Resources/config/routing.yml"
prefix: /
Instructions coming soon
Instructions coming soon