I'm trying to upload thumbnail to Post entity using Image entity. I've installed VichUploaderBundle. Image upload runs without an error but when I look at db in path field i have something like this:
/private/var/folders/6p/brq75f3j1dq2vj6sk21bgw5h0000gn/T/phpyJra9T
instead of filename. Here are my files: configm.yml
vich_uploader:
db_driver: orm
mappings:
gallery_image:
uri_prefix: /uploads/gallery
upload_destination: %kernel.root_dir%/../web/uploads/gallery
inject_on_load: false
delete_on_update: true
delete_on_remove: true
Image.php:
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private $path;
/**
*
* @Assert\File(
* maxSize = "5M",
* mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/tiff"},
* maxSizeMessage = "The maxmimum allowed file size is 5MB.",
* mimeTypesMessage = "Only the filetypes image are allowed."
* )
* @Vich\UploadableField(mapping="gallery_image", fileNameProperty="path")
*/
private $file;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
public function setFile(File $image = null)
{
$this->file = $image;
return $this;
}
/**
* @return File
*/
public function getFile()
{
return $this->file;
}
PostType:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title')
->add('body', TextareaType::class, array('required'=>false))
->add('tags', TextType::class, array('required'=> false))
->add('thumbnail', ImageType::class, ['required' => false])
;
}
ImageType:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('path', FileType::class, ['label'=>false, 'data_class' => null])
;
}
I don't have any idea where is the problem, please help me.