Symfony2,RestFul API,错误上传的文件太大。请尝试上传较小的文件

时间:2013-09-10 08:25:28

标签: php forms rest symfony

我有这个简单的Type Class

class XXXXType extends AbstractType
{
    /**
     * Build form method
     * 
     * @param FormBuilderInterface $builder Builder interface
     * @param array                $options Options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('XXX', 'integer');
    }

    /**
     * Set default options to the type
     * 
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'csrf_protection' => false
        ));
    }

    /**
     * Get type name
     * 
     * @return string
     */
    public function getName()
    {
        return '';
    }
}

和我的控制器

/**
 * Create a new XXXX
 * 
 * @param Request $request Action Request
 * 
 * @Route("/XXXX")
 * @Method({"POST"})
 * 
 * @ApiDoc(
 *  resource=true,
 *  description="XXXXX",
 *  input="XXXType"
 * )
 */
public function setXXXXXXAction(Request $request)
{
    $form = $this->createForm(new XXXType());
    $response = new JsonResponse();
    $form->submit($request);
    if ($form->isValid()) {
        return $response->setStatusCode(201);
    }

    return $response
            ->setData(array('Message' => $form->getErrorsAsString(0)))
            ->setStatusCode(500);
}

我总是从表单中收到同样的错误:

  

“错误:上传的文件太大。请尝试上传较小的文件。\ XXX:\ n没有错误\ n

1 个答案:

答案 0 :(得分:0)

是symfony2.3的错误

修复了那里:https://github.com/symfony/symfony/pull/9048