constraints - Symfony upload files with VichUploaderBundle, filename is null -


i don't know yet how put this. i'm working on form, used create documents , should able upload attachments (doesn't matter document type!) i'm using vichuploaderbundle , followed this instructions step step.

when trying upload file, following error message:

an exception occurred while executing 'insert document_file (filename, timestamp, uploader, entity) values (?, ?, ?, ?)' params [null, "2017-09-12 13:30:27", 1, 16]:

sqlstate[23000]: integrity constraint violation: 1048 column 'filename' cannot null 

so apparently filename of file not being recognized don't know start looking source of error. did maybe have same mistake or common thing , know start? i'd happy provide code! didn't yet upload code, since don't know part helpful!

update

<?php  namespace documentbundle\entity;  use doctrine\orm\mapping orm; use appbundle\entity\file basefile;  /**  * class extends base file class. mapped entity , table name different.  *  * @orm\haslifecyclecallbacks()  * @orm\table(name="document_file")  * @orm\entity  */ class file extends basefile {     /**      * @orm\manytoone(targetentity="documentbundle\entity\document", inversedby="files")      * @orm\joincolumn(name="entity", referencedcolumnname="id", nullable=true)      * @var \documentbundle\entity\document      **/     protected $entity; } 

this document_file. in basefile, $filename on nullable = false tried, changing true didn't change thing..

in document entity, have following variable:

    /**  * @orm\onetomany(targetentity="documentbundle\entity\file", mappedby="entity", cascade={"persist", "merge", "remove"}, orphanremoval=true)  * @assert\valid()  * @var \doctrine\common\collections\collection  **/ protected $files; 

and document formtype extends fileawaretype, plus says:

    $this->fileawaretype->addfileupload($builder, \documentbundle\entity\file::class); 

you didn't follow instuctions. here link https://github.com/dustin10/vichuploaderbundle/blob/master/resources/doc/usage.md documentation. instance, above entity name, forgot annotation '@vich\uploadable'.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -