Closed 01sup closed 9 years ago
There is probably an error in your mapping or in the form definition. Could you paste these two classes here?
<?php
namespace ENSA\PortailWebLaboratoireBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Symfony\Component\HttpFoundation\File\File; use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
@Vich\Uploadable / class Article { /*
/////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// /////// THIS IS WHAT I ADDED (VichUploaderBundle)/////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
/**
/**
/**
/**
if ($image) { // It is required that at least one field changes if you are using doctrine // otherwise the event listeners won't be called and the file is lost $this->updatedAt = new \DateTime('now'); } }
/**
/**
/**
/////////////////////////////////////////////////////////////////////////// //////////////////OTHER ATTRIBUTES THAT BELONGS TO ARTICLE ENTITY////////// /////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/**
/**
/**
/**
/**
//CONSTRUCTEUR PAR DEFAUT public function __construct(){
$this->date = new \DateTime("now");
}
/**
/**
return $this; }
/**
/**
return $this; }
/**
/**
return $this; }
/**
/**
return $this; }
/**
/**
return $this; }
/**
/**
}
It seems that you forgot to add the @Vich\Uploadable
annotation to your class, as specified in the documentation.
nn actually I dont forget it I deleted the entity yesterday and I forget to add this annoation today so this is not the problem, I'm getting the same error even with the annotation !
Probably a cache issue then. Once the entity is properly configured, you have to clear the cache.
I cleared the cache also (cache:clear) so this is not the problem !
should i use 2 entities one for the Article and the other for storing the file !!!
Or there is somthing wrong with this line of code : @Vich\UploadableField(mapping="product_image", fileNameProperty="imageName") *
because I dont know what mapping="product_image" means and what it's relation with my article entity !!!
And this my config.yml configuration :
vich_uploader: db_driver: orm
mappings:
espace_partage:
uri_prefix: /documents
upload_destination: %kernel.root_dir%/../web/documents
inject_on_load: false
delete_on_update: true
delete_on_remove: true
I created a folder named documents in the web folder of symfony !
update : I changed the attribute mapping to "espace_partage" and the error is not shwon anymore but nothing is added to the database !!!
UPDATE : I figure out that this issue have a relation with the size of the file (I think around 3Mo), so now I want to allow anay size of files !
maybe related to #442
YAA I foget to close this issue; tnx again :)
I have in my project an entity "Article", and i followed all the steps to add a file selector to this entity form but I get this error I dont know why :
An exception occurred while executing 'INSERT INTO article (titre, contenu, date, image_name, updated_at, professeur_id) VALUES (?, ?, ?, ?, ?, ?)' with params ["sdfsd", "sdfdsfdsvsd dsfds fsd", "2015-08-28", null, "2015-08-28 02:56:57", 70]:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'image_name' cannot be null