Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages in full color showing how to combine Symfony with Docker, APIs, queues & async tasks, Webpack, Single-Page Applications, etc.

Buy printed version

Uploadable extension

Uploadable extension

Before using this extension, read the official Uploadable documentation. Once everything is ready, use the Form component as usual. Then, after you verify the form is valid, do the following:

$document = new Document();
$form = $this->createFormBuilder($document)


if ($form->isSubmitted() && $form->isValid()) {
    $em = $this->getDoctrine()->getManager();

    $uploadableManager = $this->get('stof_doctrine_extensions.uploadable.manager');

    // Here, "getMyFile" returns the "UploadedFile" instance that the form bound in your $myFile property
    $uploadableManager->markEntityToUpload($document, $document->getMyFile());


    return $this->redirect($this->generateUrl('...'));

return $this->render('...', array('form' => $form->createView()));

And that’s it. The Uploadable extension handles the rest of the stuff. Remember to read its documentation!

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.