Open anilGupta opened 8 years ago
i used vich uploader config "inject_on_load" as true
vich_uploader: db_driver: orm # or mongodb or propel or phpcr mappings: small_image: uri_prefix: /uploads/images/small upload_destination: %kernel.root_dir%/../web/uploads/images/small namer: vich_uploader.namer_uniqid inject_on_load: true delete_on_update: true delete_on_remove: true
now when i dump my object in controller i got object with File Injected Proprieties
Movie {#679 ▼ -id: 7 -featureImageFile: -featureImageFile: File {#771 ▼ path: "C:\wamp/../web/uploads/images/feature" filename: "56cd61b786c57.jpg" basename: "56cd61b786c57.jpg" pathname: "C:\wamp\www\/uploads/images/feature\56cd61b786c57.jpg" extension: "jpg" realPath: "C:\wamp\www\uploads\images\feature\56cd61b786c57.jpg" aTime: 2016-02-24 08:54:30 mTime: 2016-02-24 08:54:30 cTime: 2016-02-24 08:54:30 inode: 0 size: 173519 perms: 0100666 owner: 0 group: 0 type: "file" writable: true readable: true executable: false file: true dir: false link: false linkTarget: "C:\wamp\...\images\feature\56cd61b786c57.jpg" } -featureImageName: "56cd61b786c57.jpg" #regions: PersistentCollection {#717 ▶} #genre: Genre {#739 ▶} #language: Language {#745 ▶} }
but when i am dumping object on sonata postUpdate(movie) save hook i am getting no information about file
public function postUpdate($movie){ dump($movie); exit; }
i got this result
Movie {#679 ▼ -id: 7 -featureImageFile: null -featureImageName: "56cd61b786c57.jpg" #regions: PersistentCollection {#717 ▶} #genre: Genre {#739 ▶} #language: Language {#745 ▶} }
here is my Movie Entity class
<?php namespace Application\NS\AdminBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Vich\UploaderBundle\Mapping\Annotation as Vich; use Symfony\Component\HttpFoundation\File\File; /** * Movie * * @ORM\Table(name="movie") * @ORM\Entity(repositoryClass="Application\NS\AdminBundle\Repository\MovieRepository") * @Vich\Uploadable */ class Movie { /** * @Vich\UploadableField(mapping="feature_image", fileNameProperty="featureImageName") * @var File */ private $featureImageFile; /** * @ORM\Column(type="string", length=255, nullable=true) * @var string */ private $featureImageName; /** * Set featureImageName * @param string $featureImageName * @return object */ public function setFeatureImageName($featureImageName) { $this->featureImageName = $featureImageName; return $this; } /** * Get featureImageName * @return string */ public function getFeatureImageName(){ return $this->featureImageName; } }
here is my admin class
/** * @param FormMapper $formMapper */ protected function configureFormFields(FormMapper $formMapper) { $formMapper ->add('featureImageFile', 'vich_image', array( 'required' => false, 'allow_delete' => true, 'download_link' => false)) }
what i am missing can any one help ? is there any alternative method to inject uploaded file information into Entity Object
Since this issue is older that 1.0.0 release, did you try with a more recent version of VichUploaderBundle?
1.0.0
i used vich uploader config "inject_on_load" as true
now when i dump my object in controller i got object with File Injected Proprieties
but when i am dumping object on sonata postUpdate(movie) save hook i am getting no information about file
i got this result
here is my Movie Entity class
here is my admin class
what i am missing can any one help ? is there any alternative method to inject uploaded file information into Entity Object