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.