Form of symfony, field of type FileType

2

I run into a problem when trying to upload images to the server using a symfony form as follows:

$form = $this->createFormBuilder($image)
        ->add('full', FileType::class, array('label' => 'Imagen', 'multiple' => true))
        ->add('save', SubmitType::class, array('label' => 'Guardar'))
        ->getForm();

Then in the html:

{{ form_start(form) }}                        
{{ form_row(form.full) }}
{{ form_end(form)  }}

When I inspect the html I get:

<form name="form" method="post" enctype="multipart/form-data">                       
      <div class="form-group">
            <label class="control-label required" for="form_full">Imagen</label>
            <input type="file" id="form_full" name="form[full][]" required="required" multiple="multiple" />
      </div>
      <div class="form-group">
            <button type="submit" id="form_save" name="form[save]" class="btn-default btn">Guardar</button>
      </div>
      <input type="hidden" id="form__token" name="form[_token]" value="vZjUzyZCsbsx5TmfWiljncIi1pPymfod_jezOOKgK_k" />
</form>

When I get the value of the file in the controller I have this:

So far, well, but in other cases of other images with the same format (jpeg), it happens that I get this:

As you can see it does not recognize the Mimetype that it should be image / jpeg, and it shows that an error occurs but it does not say which one?

    
asked by Armando Rodríguez Acosta 17.12.2018 в 19:52
source

1 answer

3

The problem is that the error = 1 means that the file you are trying to upload is larger than the limit set in the php.ini of the server, changing this parameter is solved:

php.ini:

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize=8M
    
answered by 20.12.2018 / 17:12
source