Closed treadmillian closed 3 years ago
Just a follow-up of an actual working simple example that fails. Both the above reported issue and this example work fine if I just use; symfony serve
.
Controller
/**
* @Route("/upload", name="upload_example", methods={"GET", "POST"})
*/
public function import(
Request $request
): Response {
$form = $this->createForm(UploadF307CType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
dump('Valid');
}
return $this->render('claim/upload-f307c.html.twig', [
'form' => $form->createView(),
]);
}
Form
<?php
declare(strict_types=1);
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
final class UploadF307CType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('importTemplatePath', FileType::class, [
'label' => false,
'mapped' => false,
'required' => true,
])
->add('submit', SubmitType::class, [
'label' => 'Upload',
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}
Template
{% block body %}
{{ form(form) }}
{% endblock %}
I can also confirm after downgrading the roadrunner-bundle
to 1.x
the file upload immediately worked.
Hi!
Thanks for the report!
Can you try with the changes in #38 ?
Hi,
I can confirm that fixed the issue perfectly.
Thank you!
I released 2.0.1 with the fix :)
Since upgrading to RoadRunner 2.0.4, I've noticed when attempting to upload a file to the server Symfony is reporting the error
The file could not be uploaded
(see; https://symfony.com/doc/current/reference/constraints/File.html#uploaderrormessage), but never got this with RR 1.9.2When the form gets validated, like so;
I get this error. Has anyone else had this issue? Max file upload size is set to 32M and the file is only 115K.
Path: children[importTemplatePath].data
Message: The file could not be uploaded.
Invalid value: Symfony\Component\HttpFoundation\File\UploadedFile {#250 …}
Violation:
Contents of the POST request
If I
watch -d
the/tmp
directory, I can see the file is uploaded to the server and then is immediately deleted.-rw------- 1 app app 114590 Apr 15 21:42 upload522885814