トークンとファイル フィールドのフォームに問題があります。
フォームの検証は次のようになります。
public function getDefaultOptions(array $options)
{
$collectionConstraint = new Collection(array(
'fields' => array(
'file' => new File(
array(
'maxSize' => '2M',
'mimeTypes' => array(
'application/pdf', 'application/x-pdf',
'image/png', 'image/jpg', 'image/jpeg', 'image/gif',
),
)
),
)
));
return array(
'validation_constraint' => $collectionConstraint
}
無効なサイズのファイル (~5MB) をアップロードすると、次のエラーが表示されます。
The file is too large. Allowed maximum size is 2M bytes
しかし、大きすぎるファイル (~30MB) をアップロードすると、エラーが変わります:
The CSRF token is invalid. Please try to resubmit the form
The uploaded file was too large. Please try to upload a smaller file
問題はエラートークンです。私は自分のフォームに {{ form_rest(form) }} コードを入れました。エラーの変更はこれが原因だと思います: Symfony 2フォームのファイルのアップロード制限を増やす方法は?
アップロード制限を増やしたくありません。トークンエラーが表示されないようにしたい。