Multiple file upload with Symfony2

后端 未结 11 819
温柔的废话
温柔的废话 2020-12-01 02:12

I\'m trying to upload multiple files via a form, but I can only upload one file at a time, the last one I mark in the browser. Is there a way to upload more images with Symf

11条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-01 02:46

    use this methode :

    $form = $this->createFormBuilder()
    ->add('attachments','file', array('required' => true,"attr" => array(
      "multiple" => "multiple",
      )))
    ->add('save', 'submit', array(
      'attr' => array('class' => 'btn btn-primary btn-block btn-lg'),
      'label' => 'save'
      ))
    ->getForm();
    

    then you add [] to the name of your input via jQuery :

    
    

    jQuery code :

     
    

提交回复
热议问题