I'm facing a very strange problem.
I try to realize a simple attachment uploader with Symfony2 and Doctrine.
So I followes this cookbook article http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html
And everything seems fine, but PHP throws a fatal error when I try to upload a 140KB file.
This is my validation:
/**
* @Assert\File(
* maxSize="4M",
* maxSizeMessage="Allowed maximum size is {{ limit }}"
* )
*/
public $file;
and this is my php.ini
memory_limit = 256M
max_input_time = 60
max_execution_time = 30
file_uploads = On
upload_max_filesize = 128M
So everything should be fine, the script need something about 500ms to get to the error: Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 122 bytes)
When I increase the memory_limit it doesn't change anything, memory size increases but it still tried to allocate 122 bytes. Everything else works totally fine, just the file upload breakes.
Any guesses what is going on?
Edit:
Yes I did the {{ form_enctype(form) }}, so I'll post the uploadAction. It's pretty complicated because the model is full of foreign keys, I'll cut out the parts, that don't matter:
public function createAction(Request $request)
{
$em = $this->getDoctrine()->getEntityManager();
$conference = new Conference();
$conference->setArchived(false);
$conference->setLastModification(new \DateTime());
$form = $this->createForm(new ConferenceType(), $conference);
if ($request->getMethod() == 'POST') {
$form->bindRequest($request);
if ($form->isValid()) {
$registrationForm = $conference->getRegistrationForm();
$em->persist($conference->getLocation());
$conference->getImage()->upload();
$em->persist($conference->getImage());
// lots of other stuff is going on (does not refer to the upload processs
$em->flush();
return $this->redirect($this->generateUrl('KnowHowERegistrationBackendBundle_registrationform_create'));
}
}
return $this->render('KnowHowERegistrationBackendBundle:Conference:create.html.twig',
array(
'form' => $form->createView(),
'conference' => $conference
));
}
I hope somebody is able to reproduce it or find a solution.