上传多张照片symfony2

时间:2016-11-21 23:21:52

标签: image symfony controller upload syntax-error

我遵循了以下教程:https://symfonytricksandcheats.wordpress.com/2015/11/05/subir-multiples-ficheros-a-la-vez/

以下后会返回以下错误:

Error: Uncaught TypeError: Argument 1 passed to Symfony\Component\Debug\ErrorHandler::handleException() must be an instance of Exception, instance of Error given in /Applications/MAMP/htdocs/miweb/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php:436
Stack trace:
#0 [internal function]: Symfony\Component\Debug\ErrorHandler->handleException(Object(Error))
#1 {main}
thrown

我不太明白,我看到的是错误在控制器中,即:

public function createAction(Request $request)
    {
        $album = new Album();
        $form = $this->createForm(new AlbumType(), $album);
        **$form->handleRequest($request);**

        if ($form->isValid())
        {
            // Handle the uploaded images
            $files = $form->getData()->getPicture();

     ...

如果我删除粗体的代码,它不会给我这个错误,它给了我另一个不同的,但它是唯一的代码,如果我删除它改变了显示我的错误。

嫩枝:


            

{{ form_label(form.name) }} {{ form_widget(form.name) }}

{{ form_label(form.picture) }} {{ form_widget(form.picture, { 'full_name': 'simplex_album[picture]' ~ '[]' } ) }}

{% if error is defined %} {% for errorMessage in error %}
  • {{ errorMessage }}
  • {% endfor %} {% endif %} {{ form_rest(form) }}

    0 个答案:

    没有答案