【发布时间】:2015-06-21 22:23:49
【问题描述】:
我想用 VichUploaderBundle 上传文件。有我的实体
........
/**
*
* @Vich\UploadableField(mapping="product_image", fileNameProperty="imageName")
*
* @var File $imageFile
*/
protected $imageFile;
/**
* @ORM\Column(type="string", length=255, name="image_name")
*
* @var string $imageName
*/
protected $imageName;
/**
* @ORM\Column(type="datetime")
*
* @var \DateTime $updatedAt
*/
protected $updatedAt;
/**
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
*/
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
if ($image) {
$this->updatedAt = new \DateTime('now');
}
}
/**
* @return File
*/
public function getImageFile()
{
return $this->imageFile;
}
/**
* @param string $imageName
*/
public function setImageName($imageName)
{
$this->imageName = $imageName;
}
/**
* @return string
*/
public function getImageName()
{
return $this->imageName;
}
.........
我的表单生成器看起来像
........
$builder
->add('brand')
->add('model')
->add('price')
->add('imageName')
->add('updatedAt')
->add('sub_rel')
.......
我的配置文件看起来像
vich_uploader:
db_driver: orm
mappings:
product_image:
uri_prefix: /images/goods
upload_destination: %kernel.root_dir%/../web/images/goods
inject_on_load: false
delete_on_update: true
delete_on_remove: true
问题: 我需要更改哪些内容才能使用此捆绑包下载几张图片?
【问题讨论】:
-
您能进一步解释一下吗?您想在一个视图中显示许多图像并有下载链接吗?您希望能够通过直接链接/api 下载它们吗?
-
@gvf 我想在管理面板中为我的商品上传图片
-
我认为每个实例只能上传一张图片。您不能使用 vichuploader 处理同一属性的多个文件。不过我已经有一段时间没用了,也许改变了
-
下载还是上传?
标签: php symfony vichuploaderbundle