I am tying to make stof/StofDoctrineExtensionsBundle
work with symfony3
. Therefore instead of using $form->bind
as listed in example in stof documentation I tried $form->handleRequest
. Unluckily after submitting the form I get the following error:
The file "" does not exist
I would be thankful for you advise what am I doing wrong. Maybe somebody would be so kind and provide me with example of working upload scripts?
My Controller code looks like this:
public function plikAction(Request $request, $dok_id, $plik_id)
{
$em = $this->getDoctrine()->getManager();
if($plik_id == "nowy") $plik = new plik();
/.../
$form = $this->createForm(plikType::class, $plik);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
if($plik_id == "nowy")
{
$em->persist($plik);
$uploadableManager = $this->get('stof_doctrine_extensions.uploadable.manager');
$uploadableManager->markEntityToUpload($plik, $plik->getName());
$em->flush();
$this->get('session')->getFlashBag()->add('success','Dodano plik ');
}
/.../
}
form is build using the following function:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('oznaczenie')
->add('name', FileType::class)
->add('wgraj', SubmitType::class);
}
and my entity class:
/**
* @ORM\Entity
* @ORM\Table
* @Gedmo\Uploadable
*/
class plik
{
/**
* @ORM\Column
* @Gedmo\UploadableFileName
*/
private $name;
/*
* @ORM\Column(type="string", length=100)
* @Gedmo\UploadableFilePath
*/
protected $path;
I am using default configuration as listed here https://symfony.com/doc/master/bundles/StofDoctrineExtensionsBundle/index.html.
In my case the Symfony3
error:
The file “” does not exist
was connected with PHP not being able write the file down to temporarily folder due to open_basedir
restrictions.
Therefore in any case you see this error in Symfony3 make sure that correct permissions are set to folders and that PHP may write data into it.